How to convert #defined string literal to wide string literal?

Possible duplicate:
How to convert concatenated strings to widescreen char with C preprocessor?

I have a string literal defined with #define:

#define B "1234\0" 

How to use this definition to get this wide literal at compile time ?:

 L"1234\0" 

(only the string literal #define d with L added to turn it into a wide string).

I tried this:

 #define MAKEWIDE(s) L##s 

but it generates LB

+4
source share
2 answers

Marker insertion requires an additional level of indirection for the proper processing of macros used as operands. Try something like:

 #define PASTE(x, y) x##y #define MAKEWIDE(x) PASTE(L,x) 
+5
source

This will work just fine:

 #define B "1234\0" #define LB L"" B 
+7
source

All Articles