问题是内部如何typedef
工作?
PS:我确实在各种网站上进行了搜索,包括维基百科和各种。但他们都没有回答这个问题。因此问题。
进一步澄清:我确实了解了它的作用,但它的作用是问题。
typedef
没有指定任何编译器如何处理 a ;很可能类型信息被保存为该名称的符号表条目的一部分,并且在源代码中遇到类型名称的任何地方,在翻译过程中都会替换等效的类型信息。
typedef
是关键字 in C
,它为程序员提供了一个工具来制作自己的别名
data type
来自其他类型或现有的内置类型。
这就是语言的样子,也是它的实现方式。
typedef <given_type> <new_type>
仅供参考:如果你这样做
int a
它由编译器解析,然后它知道这a
是一个类型的变量int
。并相应地分配内存。
同样,每当typedef
找到关键字时,它就会假定紧随其后的类型是 the old_type
,而其他新标识符是new_type
。
编辑 :
ISO c99:存储类说明符
The typedef specifier is called a ‘‘storage-class specifier’’ for syntactic convenience
only.If, in a parameter declaration, an identifier can be treated either as a typedef name or as a parameter name, it shall be taken as a typedef name.A typedef declaration does not introduce a new type, only a synonym for the type so specified