I have following code:
#include <stdio.h>
#ifdef COMP_DEF
static const char * x = COMP_DEF;
#else
static const char * x = "NULL";
#endif
int main(int argc, char ** argv)
{
printf("%s\n", x);
return 0;
}
What I want is to compile this program with two ways. First with compiler parameter:
-DCOMP_DEF=FOO_BAR
and second way without this. I expect, my program would print FOO_BAR and NULL. But when I try to compile I get following errors:
:0:10: error: 'FOO_BAR' undeclared here
(not in a function) main.c:5:25: note: in expansion of macro 'COMP_DEF' static const char * x = COMP_DEF;
Is it possible to print/store in variable compiler passed macrodefine value?