C 中的类型命名空间 [英] type namespace in C

查看:38
本文介绍了C 中的类型命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了关于 C 中定义类型的不同命名空间的内容,例如有一个用于 Structs 和 Unions 的命名空间以及一个用于 typedef 的命名空间.

I've read in SO about different namespaces in C where the type are defined, e.g. there is a namespace for Structs and Unions and a namespace for typedefs.

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

Is namespace the exact name for this? How many namespaces exist in C?

推荐答案

见 6.2.3

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

6.2.3 标识符的命名空间

6.2.3 Name spaces of identifiers

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 中的类型命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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