结合宽字符串文字与字符串宏 [英] Combining wide string literal with string macro

查看:165
本文介绍了结合宽字符串文字与字符串宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串的宏如下:

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.

有没有办法给APPNAME宏转换为宽字符串文字?

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

推荐答案

你有没有尝试

#define APPNAME "MyApp"

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

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

这篇关于结合宽字符串文字与字符串宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆