Answer the question
In order to leave comments, you need to log in
How to set C preprocessor behavior in GCC?
Hello.
There is some code:
#ifdef func
#define temp func
#undef func
#endif
// тут выполняется какой-то код
#ifdef temp
#define func temp
#undef temp
#endif
Answer the question
In order to leave comments, you need to log in
Its meaning is simple: cancel the action of the macro in a certain part of the code, and after it expires, restore this macro.
#define temp func
value of the func macro is written, it is not substituted. The word literally gets into temp func
. After #undef func
the contents of the func macro will be lost. This behavior is prescribed by the standard, I don't know any compiler options that could change it. See eelis.net/c++draft/cpp.replace#10 and eelis.net/c++draft/cpp.rescan#define foo bar
#define func foo
...
#undef func
...
#define func foo
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question