The only thing wrong with your last example is failure to include 'struct' before it, that and you haven't named your structure. I'd do something like:
Code:
struct personalityTypes {
int ident;
int (*chose)(void);
int (*decide)(int);
};
Then build a table, I think you could use your macro, but let me clarify, you want a compile-time list change, not a runtime? A compile time change could use something like:
Non-macro version:
Code:
struct personalityTypes personalityTable[] =
{
{ kind, kind_choose, kind_decide },
{ usurper, usurper_choose, usurper_decide },
... more ...
};
Or, with slight modification, your macro might work, I personally haven't tried, but I believe it should do the trick:
Macro version:
Code:
#define PERSONALITY(A) { A, A ## _chose, A ## _decide }
struct personalityTypes personalityTable[] =
{
PERSONALITY(kind),
PERSONALITY(usurper),
PERSONALITY(egoist)
}
That should do the trick.
Quzah.