Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combining wide string literal with string macro

I have a macro for a character string as follows:

#define APPNAME "MyApp"

Now I want to construct a wide string using this macro by doing something like:

const wchar_t *AppProgID = APPNAME L".Document";

However, this generates a "concatenating mismatched strings" compilation error.

Is there a way to convert the APPNAME macro to a wide string literal?

like image 367
flashk Avatar asked Dec 17 '22 04:12

flashk


1 Answers

Did you try

#define APPNAME "MyApp"

#define WIDEN2(x) L ## x
#define WIDEN(x) WIDEN2(x)

const wchar_t *AppProgID = WIDEN(APPNAME) L".Document";
like image 70
Marcel Gosselin Avatar answered Dec 28 '22 12:12

Marcel Gosselin