c++ - 怎样重新定义宽字符前缀(L)
迷茫
迷茫 2017-04-17 13:25:13
0
2
468

我需要让代码同时支持宽字符和窄字符,所以需要控制L的使用

1 #define WIDESTRPREFIX L
2 std::wstring aa = L"ABC";
3 std::wstring bb = WIDESTRPREFIX"ABC";

这段代码会提示这样的错误

第三行: 3 error C2065: 'L' : undeclared identifier

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(2)
洪涛

I don’t know why your code doesn’t work, I just know that this way of writing is fine

#define WIDESTRPREFIX(a) L##a
std::wstring bb = WIDESTRPREFIX("ABC");

I don’t quite understand the purpose of this. Maybe I can use a template?

Peter_Zhu

C++14? operator""

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template