C++ Translation Phase Confusion
- by blakecl
Can someone explain why the following doesn't work?
int main() // Tried on several recent C++ '03 compilers.
{
#define FOO L
const wchar_t* const foo = FOO"bar"; // Will error out with something like: "identifier 'L' is undefined."
#undef FOO
}
I thought that preprocessing was done in an earlier translation phase than string literal operations and general token translation.
Wouldn't the compiler be more or less seeing this:
int main()
{
const wchar_t* const foo = L"bar";
}
It would be great if someone could cite an explanation from the standard.