gpt4 book ai didi

c++ - C++ 中的 L 前缀究竟是什么?

转载 作者:IT老高 更新时间:2023-10-28 14:01:09 26 4
gpt4 key购买 nike

我了解它的作用:将字符串文字指定为 const wchar_t *(宽字符串)而不是 const char *(普通旧字符),但是如何真的定义了吗?

它是某种宏吗?它是 GCC 编译器的运算符吗? 是什么

最佳答案

字面前缀是核心语言的一部分,很像后缀:

'a'    // type: char
L'a' // type: wchar_t

"a" // type: char[2]
L"a" // type: wchar_t[2]
U"a" // type: char32_t[2]

1 // type: int
1U // type: unsigned int

0.5 // type: double
0.5f // type: float
0.5L // type: long double

请注意,wchar_t 与 Unicode 没有任何关系。这是 extended rant of mine主题。

关于c++ - C++ 中的 L 前缀究竟是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13087219/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com