This bug is similar to bug 17122 ( http://llvm.org/bugs/show_bug.cgi?id=17122 ), except the bug happens in the macro, not in the use of the macro. Input: #define STRINGIZE_LITERAL(x) L#x #define STRINGIZE(x) STRINGIZE_LITERAL(x) Output: #define STRINGIZE_LITERAL(x) L #x #define STRINGIZE(x) STRINGIZE_LITERAL(x) (Note the space inserted after the L) Unfortunately I don't know anything about the preprocessor, so I don't know if this STRINGIZE macro is just bogus. Example: C:\Users\billy_000\Desktop>type example.cpp #include <cstdio> #define HELLO_VERSION 1.0.0 #define STRINGIZE_LITERAL(x) L#x #define STRINGIZE(x) STRINGIZE_LITERAL(x) int main() { wchar_t const* message = L"Hello, my version is " STRINGIZE(HELLO_VERSION) L"\n"; fwprintf(stdout, message); } C:\Users\billy_000\Desktop>cl /EHsc /W4 /nologo example.cpp && example.exe example.cpp Hello, my version is 1.0.0 C:\Users\billy_000\Desktop>clang++ -o example_clang.exe example.cpp example.cpp:9:54: error: expected ';' at end of declaration wchar_t const* message = L"Hello, my version is " STRINGIZE(HELLO_VERSION) L"\n"; ^ ; 1 error generated. C:\Users\billy_000\Desktop>clang-format -style=LLVM -i example.cpp C:\Users\billy_000\Desktop>type example.cpp #include <cstdio> #define HELLO_VERSION 1.0.0 #define STRINGIZE_LITERAL(x) L #x #define STRINGIZE(x) STRINGIZE_LITERAL(x) int main() { wchar_t const *message = L"Hello, my version is " STRINGIZE(HELLO_VERSION)L"\n"; fwprintf(stdout, message); } C:\Users\billy_000\Desktop>cl /EHsc /W4 /nologo example.cpp && example.exe example.cpp example.cpp(9) : error C2146: syntax error : missing ';' before identifier 'L' example.cpp(9) : error C2065: 'L' : undeclared identifier example.cpp(9) : error C2143: syntax error : missing ';' before 'string' example.cpp(9) : error C2308: concatenating mismatched strings Concatenating narrow "1.0.0" with wide " " C:\Users\billy_000\Desktop>clang++ -o example_clang.exe example.cpp example.cpp:9:31: error: expected ';' at end of declaration L"Hello, my version is " STRINGIZE(HELLO_VERSION)L"\n"; ^ ; 1 error generated. Thanks!
Fixed in r190408.
(In reply to comment #0) > #define STRINGIZE_LITERAL(x) L#x > #define STRINGIZE(x) STRINGIZE_LITERAL(x) [...] > Unfortunately I don't know anything about the preprocessor, so I don't know > if this STRINGIZE macro is just bogus. It is. With a correct preprocessor, this will always produce two separate tokens: an 'L' token and a string literal.
Yep, the correct implementation is: #define STRINGIZE_LITERAL(x) L ## #x But L#x implementation seems to be relatively wide-spread due to Visual C++ allowing it. I'd keep the fix so that we don't break existing code.
Thanks very much guys :) I'll fix the STRINGIZE_LITERAL macro too.