Let's pretend that
#define Name Joe
Is there a way to distinguish between different values for a macro. The following don't work, but you get the idea
#if Name==Joe // some code #elif Name==Ben // some alternative code #endif
I want to use this to create various object files from one source code. The source is a little different, so it can be easily controlled with macros. The macro must be passed using the compiler flag -DName=Joe . Also note that Name will be the actual name of the symbol, so we won’t be able to use tricks based on #define Joe 1 , etc.
forced editing Please note that this similar question really deals with string characters. Moreover, the answers there do not help. The accepted answer avoids the problem (but does not solve it), another answer uses strcmp in macros that rely on the extension, etc.
macros c-preprocessor preprocessor-directive
Walter
source share