像_NAME符号的含义,__NAME,_NAME_,__name__ [英] Meaning of notations like _NAME, __NAME, _NAME_, __NAME__

查看:118
本文介绍了像_NAME符号的含义,__NAME,_NAME_,__name__的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在无数的C / C ++头文件和源文件看到了这一点。结果
除了个人preference,什么是这些不同的符号的含义?

I've seen this in countless C/C++ header and source files.
Apart from personal preference, what's the meaning of each of these different notations?


  • _NAME

  • __名称

  • _NAME _

  • __ __名称

  • NAME_t

  • _NAME
  • __NAME
  • _NAME_
  • __NAME__
  • NAME_t

坦率地说,我唯一COM prehend是 _NAME ,这是一个类(至少在C#这是)的私有成员。

Quite honestly, the only one I comprehend is _NAME, which is a private member of a class (at least in C# it is).

有人能解释其中的区别呢?结果
并且,如果有任何其他明显的记号作为这样,请提及它们(甚至在其他类似的语言)。

Can someone explain the difference among them?
And if there are any other noticeable notations as such, please mention them (even in other similar languages).

谢谢!

推荐答案

开头的名称_ __ 通常是保留的标识符,你不应该定义/创建与该公约开头的标识符。 (_用大写以下)

Names that begin with _ or __ are typically for reserved identifiers, and you should not define/create identifiers that begin with that convention. (_ with Upper Case following)

从C99标准7.1.3 - 保留标识符

From C99 standard, 7.1.3 - "Reserved Identifiers"

- 所有鉴定连接器与下划线和大写字母或其他开头
  下划线,始终保留用于任何用途。

— All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use.

- 所有鉴定连接器以下划线开头总是保留用作鉴定连接器
  在这两个普通和标记的名称空间连接的文件范围。

— All identifiers that begin with an underscore are always reserved for use as identifiers with file scope in both the ordinary and tag name spaces.

从C ++ 03标准(修订C ++ 98),一节17.4.3.1.2 - 全局名称

From C++03 Standard (amendment to C++98), section 17.4.3.1.2 - "Global Names"

- 包含一个双下划线(_ _)或以下划线后跟一个大写开头的每个名称
  字母(2.11)是保留用于任何用途的实现。

— Each name that contains a double underscore (_ _) or begins with an underscore followed by an upper- case letter (2.11) 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

这篇关于像_NAME符号的含义,__NAME,_NAME_,__name__的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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