为什么人们在C ++中使用__(双下划线) [英] Why do people use __(double underscore) so much in C++

查看:196
本文介绍了为什么人们在C ++中使用__(双下划线)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在看看一些开源的C ++代码,并注意到在代码中使用的很多double,主要是在变量名的开头。

I was having a look through some open source C++ code and notice a lot of double under scores where used in the code, mainly at the start of variable names.

return __CYGWIN__;

只是想知道是有原因的,还是只是一些人的代码样式?我认为我很难阅读。

Just wondering is there a reason for this, or is it just some people code styles? I would think that I makes it hard to read.

推荐答案

C ++中的计划,规则和建议


标识符中两个下划线(`__')的使用是为编译器根据ANSI-C标准内部使用而保留的。

The use of two underscores (`__') in identifiers is reserved for the compiler's internal use according to the ANSI-C standard.

)通常用在库函数的名称中(例如_main和_exit)。为避免冲突,请勿使用下划线开始标识符。

Underscores (`_') are often used in names of library functions (such as "_main" and "_exit"). In order to avoid collisions, do not begin an identifier with an underscore.

这篇关于为什么人们在C ++中使用__(双下划线)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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