I want to replace the macro with the corresponding type with the same name. I have
#define FooType char*
in a third-party library, and this breaks some of my code (more precisely: some code that I have to use, and which I cannot change myself). I want to replace it with a typedef with the same name, and then #undef with a macro. I tried something like this:
#define TMP_MACRO FooType #undef FooType typedef TMP_MACRO FooType; #undef TMP_MACRO
But the preprocessor extends this value to:
typedef FooType FooType;
(at least that's what g++ -E told me). Therefore, the TMP_MACRO macro TMP_MACRO not expand immediately. Since "FooType" does not exist, it does not compile.
How can I replace the FooType macro FooType the correct type and subsequently define the macro? Or is it impossible?
Sh4pe source share