search

Home  >  Q&A  >  body text

c++ - 怎样重新定义宽字符前缀(L)

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

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

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

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

迷茫迷茫2803 days ago463

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 13:27:13

    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?

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 13:27:13

    C++14? operator""

    reply
    0
  • Cancelreply