Like _T()
macro in Visual Studio, I defined and used my own _L
macro as:
#define _L(x) __L(x)
#define __L(x) L ## x
It works for:
wprintf(_L("abc\n"));
But gets a compilation error for:
wprintf(_L("abc\n""def\n"));
It reports “string literals with Iifferent character kinds cannot be concatenated”.
I also did:
#define _L2(x) __L2(x)
#define __L2(x) L ## #x
wprintf(_L2("abc\n""def\n"));
The code gets compiled, but the \n
doesn't work as an escape sequence of a new line. The \n
becomes two characters, and the output of wprintf
is:
"abc\n""def\n"
How I can have a macro to convert two concatenated char string to wchar_t
? The problem is I have some already existing macros:
#define BAR "The fist line\n" \
"The second line\n"
I want to covert them to a wchar
string during compilation. The compiler is ICC in windows.
Edit:
The _L
macro works in gcc, the MSVC and ICC didn't works, it's a compiler bug.
Thanks @R.. to comment me.
L""
is the standard, canonical way to convert to a wide string. – Ivo