I’m trying to get the pre-processor to generate a list based on which names have been defined. Something like this
#define LIST "Start of list!"
#ifdef WITH_FOO
#define LIST LIST "Foo"
#endif
#ifdef WITH_BAR
#define LIST LIST "Bar"
#endif
#define LIST LIST "End of list!"
I get some warnings from this about LIST being redefined, and then later in the code where I try to use the LIST it gives an error: “LIST was not declared in this scope” which, warnings aside, I believe it should be.
How can I get this to work?
You could use some auxiliary macros: