I would like to define a macro based on whether -std=c++0x
is used.
If I try the macro below I have error error stray '#' in program
.
Is the code below incorrect / is it allowed C++ to use preprocessor #if / #endif
within a #define
?
#define DEF_ME (p) \
#if __GXX_EXPERIMENTAL_CXX0X__ \
#endif
I am using g++ 4.4.7 in Linux.
Is the code below incorrect / is it allowed C++ to use preprocessor
#if
/#endif
within a#define
?
No, that’s not allowed. But you can use the opposite to get the same result:
#if __GXX_EXPERIMENTAL_CXX0X__
# define DEF_ME (p) one way
#else
# define DEF_ME (p) another way
#endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With