If I have a #define statement within a namespace as such:
namespace MyNamespace
{
#define SOME_VALUE 0xDEADBABE
}
Am I correct in saying that
I completely agree with the suggestions on the use of constants and the scope being unlimited for #define
s.
However, if you do have to use preprocessor #define
lines, please cover them up correctly for the expected scope,
namespace MyNamespace
{
#define SOME_VALUE 0xDEADBABE
// your code
#undef SOME_VALUE
}
Why #defines
?
I know one case where an embedded platform did not support constants in the code.
There was no way to initialize them...
It always helps to be more readable.