gpt4 book ai didi

c - C变量名定义中下划线的原因是什么?

转载 作者:太空宇宙 更新时间:2023-11-04 04:11:38 24 4
gpt4 key购买 nike

我试图了解开发人员何时需要定义带有前缀“_”的 C 变量。这是什么原因?

例如:

uint32_t __xyz_ = 0;

最佳答案

也许这有帮助,来自 C99,7.1.3(“保留标识符”):

  • 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.

寓意:对于普通用户代码,标识符最好不要以下划线开头。

(在相关说明中,我认为您还应该避免使用尾随 _t 命名 types,这是为标准类型保留的。)

关于c - C变量名定义中下划线的原因是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56636569/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com