Suppose I have
#define Name Joe
Is there a way to distinguish different values for the macro. The following does not work, but you get the idea
#if Name==Joe
// some code
#elif Name==Ben
// some alternative code
#endif
I want to use this to generated various object files from the same source code. The source differs only little, so can easily be macro controlled. The macro is to be passed in via the -DName=Joe
compiler flag. Note also that the Name
will be an actual symbol name, so we cannot use tricks based on #define Joe 1
etc.
forced edit Note that this similar question actually deals with string-valued macros. Moreover the answers there don't help. The accepted answer avoids the problem (but doesn't solve it), another answer uses strcmp
in the macros, which relies on an extension, etc.