I read somewhere that
#define X defined(Y)
was an invalid expression, but it works (?)
Here an example
#define WIN_PLAT defined(_WIN32)
#if WIN_PLAT
# undef WIN_PLAT
# define WIN_PLAT 1
#else
# undef WIN_PLAT
# define WIN_PLAT 0
#endif
Thanks y’all.
Edit: fixed ‘duplicate definitions’ warning in the else branch.
>Solution :
Macros are text replacements, as long as you replace defined(Y) back into a preprocessor instruction it will work. It will however not work if you try to use it in C++ code:
cout << X; // error: undefined symbol defined