Is it possible to put a macro in a macro in c++?
Something like:
#define Something\
#ifdef SomethingElse\ //do stuff \
#endif\
I tried and it didn't work so my guess is it doesn't work, unless there's some sort of syntax that can fix it?
Is it possible to put a macro in a macro in c++?
Something like:
#define Something\
#ifdef SomethingElse\ //do stuff \
#endif\
I tried and it didn't work so my guess is it doesn't work, unless there's some sort of syntax that can fix it?
No, but you can simply refactor this by pulling the #ifdef
out as the toplevel, and using two different #define Something ...
versions for the true and false branches of the #ifdef
.
Macros, yes. Preprocessor directives, which are what you posted, no
No. I answered this in http://stackoverflow.com/questions/2506167/c-macros-with-memory
If you want to inspect or alter the preprocessing environment, in other words to define a preprocessing subroutine rather than a string-replacement macro, you need to use a header, although the legitimate reasons for doing so are few and far between.