I have a #define mapping an identifier (a function name) to a new name like this:
#define A doStuff
This part I cannot do anything about, I have to access "A" since the actual identifier (doStuff here) may change (and this is not under my control). Now the referenced symbol (doStuff) may or may not exist, and I want to invoke the function in the former case. For a plain function name I can test this easily:
#ifdef doStuff
doStuff();
#endif
However, being restricted to the macro name, doing the same naively would be:
#ifdef A
A();
#endif
which gives an error since the name "A" is defined, while "doStuff" is not. I'd like to check the existence of the name the macro resolves into, essentially:
#if defined(the-content-of-A)
but I cannot make it work.
So my question: is there any way to check whether an identifier represented by a macro is defined? If yes, how to do it? If no, is there a common pattern for a workaround?
Although I don't think that this is either C or C++ specific I'd like to note that I need something that works for an identifier defined "extern C" in C++. The solution must be platform independent.
Sorry if this was asked before, I could not find it, neither with google nor on SO.