If I have a #define statement within a namespace as such:
namespace MyNamespace
{
#define SOME_VALUE 0xDEADBABE
}
Am I correct in saying that
If, for some reason, you couldn't change to the second case, I'm pretty sure you would have to take care to compile MyNamespace into its own object and link the objects separately (or possibly just run the preprocessor on that single namespace by itself). The C++ preprocessor should take that #define
statement and essentially do a string replace anywhere that SOME_VALUE
is seen in the source code. Hence if the preprocessor is not aware of the #define
, SOME_VALUE
cannot be replaced in another source file.