I want to replace a macro with a proper typedef 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 I am forced to use and which I can’t change by myself). I want to replace it by a typedef of the same name and then #undef the macro. I tried something like that:
#define TMP_MACRO FooType
#undef FooType
typedef TMP_MACRO FooType;
#undef TMP_MACRO
But the preprocessor expands this to:
typedef FooType FooType;
(at least that is what g++ -E told me). So the macro TMP_MACRO is not expanded immediatelly. As ‘FooType’ is not there, it does not compile.
How can I replace the macro FooType by a proper type and undefine the macro afterwards? Or is this impossible?
A
typedefdeclaration is usually on one line, but line numbers mean nothing to the compiler.