开发者

Combining wide string literal with string macro

开发者 https://www.devze.com 2022-12-11 05:59 出处:网络
I have a macro for a character string as follows: #define APPNAME \"MyApp\" Now I want to construct a wid开发者_高级运维e string using this macro by doing something like:

I have a macro for a character string as follows:

#define APPNAME "MyApp"

Now I want to construct a wid开发者_高级运维e 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?


Did you try

#define APPNAME "MyApp"

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

const wchar_t *AppProgID = WIDEN(APPNAME) L".Document";


Without macros:

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

精彩评论

暂无评论...
验证码 换一张
取 消