C ++宏如何用于两个字符串文字

时间:2013-01-24 07:01:05

标签: c++ visual-c++ text literals

之前我使用过这些宏:

#define TEXT_A   _T("a")
#define TEXT_B   _T("b")

std::wstring text = TEXT_A TEXT_B;      // then text = "ab"

现在我该怎么做:

#define TEXT_A   "a"
#define TEXT_B   "b"
std::wstring text = _T(TEXT_A TEXT_B);     // i need text be "ab" but failed.  and that error is wchar_t cannot connect with char.

我正在寻找一个宏来做到这一点。

1 个答案:

答案 0 :(得分:0)

使用

std::wstring text = _T(TEXT_A) _T(TEXT_B);

更好的解决方案:stop using wstring