gpt4 book ai didi

c - C 中的类型命名空间

转载 作者:太空狗 更新时间:2023-10-29 15:24:44 25 4
gpt4 key购买 nike

我在 SO 中读到了 C 中定义类型的不同 namespace ,例如有一个用于结构和 union 的命名空间以及一个用于 typedef 的命名空间。

命名空间是这个的确切名称吗? C 中有多少命名空间?

最佳答案

见 6.2.3

来自 http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf

6.2.3 标识符的命名空间

If more than one declaration of a particular identifier is visible at
any point in a translation unit, the syntactic context disambiguates uses
that refer to different entities.

Thus, there are separate name spaces for various categories of identifiers,
as follows:
— label names (disambiguated by the syntax of the label declaration and use);

— the tags of structures, unions, and enumerations (disambiguated by
following any32) of the keywords struct, union, or enum);

— the members of structures or unions; each structure or union has a
separate name space for its members (disambiguated by the type of the
expression used to access themember via the . or -> operator);

— all other identifiers, called ordinary identifiers (declared in ordinary
declarators or as enumeration constants).

关于c - C 中的类型命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12579142/

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