C ++中的L前缀究竟是什么? [英] What exactly is the L prefix in C++?
本文介绍了C ++中的L前缀究竟是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道它的作用:指定一个字符串文字作为 const wchar_t *
(宽字符串)而不是 const char *
(plain plain characters),但它是如何实际定义的?
I understand what it does: specifies a string literal as a const wchar_t *
(wide character string) instead of const char *
(plain old characters), but how is it actually defined?
这是一个宏吗?它是GCC编译器的运算符吗?
Is it a macro of some sort? Is it an operator for GCC compilers? What is it?
推荐答案
字面前缀是核心语言的一部分,后缀:
The literal prefixes are a part of the core language, much like the suffixes:
'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相关。以下是有关此主题的扩展的我的权限。
Note that wchar_t
has nothing to do with Unicode. Here is an extended rant of mine on the topic.
这篇关于C ++中的L前缀究竟是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文