Reputation: 53
Is there a way to insert preprocessor macro using another preprocessor macro?
Can I do something like, for instance
#define INSERT_MACRO(x) {#ifdef MYFLAG x; #endif}
so that when I write
INSERT_MACRO(foo(););
it is converted to
#ifdef MYFLAG
foo();
#endif
? Thanks!
Upvotes: 0
Views: 55
Reputation: 471
You cannot use another preprocessor directive in define. Instead you may consider,
#ifdef MYFLAG
#define INSERT_MACRO(x) x;
#else
#define INSERT_MACRO(x)
#endif
Upvotes: 1