根据最新的C ++标准,以下划线开头的标识符是否保留? [英] Are identifiers starting with an underscore reserved according to the latest C++ standard?

查看:630
本文介绍了根据最新的C ++标准,以下划线开头的标识符是否保留?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

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

I'm interested in the relevant sections from the standard (if any).

推荐答案

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

Yes, when the underscore is followed by another underscore or an uppercase letter (i.e. for preprocessor #defines or macros), or if the identifier is in the global namespace (§17.6.4.3.2):


某些名称和函数签名集合始终保留实现:

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

- 包含双下划线_ _或以下划线开头,后跟大写字母(2.12)的每个名称都保留给实现以供任何使用。

— 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,强调我):

Note that the first point means that if two underscores appear anywhere in the identifier, even in the middle or at the end, the name is reserved. Also, I would add (§17.6.4.3.5, emphasis mine):


文字后缀标识符

这篇关于根据最新的C ++标准,以下划线开头的标识符是否保留?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆