c++ - 是否根据最新的 C++ 标准保留以下划线开头的标识符?

标签 c++ c++11 standards

<分区>

Possible Duplicate:
What are the rules about using an underscore in a C++ identifier?

我对标准中的相关部分(如果有)感兴趣。

最佳答案

是的,当下划线后跟另一个下划线或大写字母(即预处理器 #defines 或宏)时,或者如果标识符位于全局命名空间中(§17.6.4.3.2):

Certain sets of names and function signatures are always reserved to the implementation:

— Each name that contains a double underscore _ _ or begins with an underscore followed by an uppercase letter (2.12) is reserved to the implementation for any use.

— Each name that begins with an underscore is reserved to the implementation for use as a name in the global namespace.

注意,第一点的意思是,如果两个下划线出现在标识符中任何地方,即使是在中间或者末尾,这个名字也是保留的。另外,我要添加(§17.6.4.3.5,强调我的):

Literal suffix identifiers that do not start with an underscore are reserved for future standardization.

关于c++ - 是否根据最新的 C++ 标准保留以下划线开头的标识符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12924243/

相关文章:

C++ 在 try block 中创建对象,然后将它们存储在 std::array 中

c - C 中的名称修饰

c++ - 轴对齐边界框的点云库旋转

c++ - 如何在 C++ 中正确重载 "<<"运算符?

C++ 返回值优化

c++11 - 为 C++ 标准库配置 clang-check

递归表达式类中的 C++ 运算符重载

java - 哪个修饰符应该先出现?

c# - 函数应该以 "Get"开头?

c++ - 使用 getchar() 函数