I have a symbol defined globally that needs to be conditionally undefined for a given subset of my source files. All of the files that require special treatment are already wrapped in pre- and post-inclusions:
pre.h:
#undefine mysymbol // [1]
post.h:
#define mysymbol MY_SYMBOL_DEFINITION // [2]
My problem is that the pre.h
and post.h
can be included multiple times for a given source file due to various inclusion chaining. As such, I need [1] to happen the first time pre.h is included and I need [2] to happen the last time that post.h
is included. Conceptually:
pre // undefine pre // no-op pre // no-op post // no-op post // no-op post // redefine
Since I am using gcc 3.4.6, I do not have access to the push and pop macro pragmas that might otherwise solve this issue for me.
How can I emulate that behavior with the remaining preprocessor functionality?
I was attempting to do something like increment/decrement a value with the preprocessor but I'm not sure that's possible.
EDIT: "What am I really trying to do?"
We have macros to replace new
with new(__FILE__, __LINE__)
-- see my other question on this topic -- and we need to undefine those macros in the set of source files wrapped by the pre- and post-includes described above because we were unable to create a macro that's compatible with the placement new syntax used therein.