Suppose I have a .cpp file in which I have to include a third-party header file that declares some symbol (let’s call it div). I do not need this symbol, but I need to define my own div symbol. However, the original symbol might be used by some other part of the header file. Is it possible to remove the symbol from global namespace (something similar to undefing a macro)?
I want something like this:
#include <string> //stdlib.h defines div symbol
//do some symbol removal magic here
std::string div;
to compile using gcc-4.7/clang with -std=c++11 option.
Basically, no.
But as the others say you can use a namespace instead to get the same effect with what is actually essentially a completely different symbol.