0

问题是内部如何typedef工作?

PS:我确实在各种网站上进行了搜索,包括维基百科和各种。但他们都没有回答这个问题。因此问题。

进一步澄清:我确实了解了它的作用,但它的作用是问题。

4

2 回答 2

0

typedef没有指定任何编译器如何处理 a ;很可能类型信息被保存为该名称的符号表条目的一部分,并且在源代码中遇到类型名称的任何地方,在翻译过程中都会替换等效的类型信息。

于 2012-12-04T12:11:16.800 回答
0

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

于 2012-12-04T11:18:09.373 回答