从标准N1570 6.7.8:
一个
typedef声明不引入新的类型,只为使指定类型的代名词.
所以我预计不可能这样写:
typedef t;
t *t_ptr;
Run Code Online (Sandbox Code Playgroud)
它应该无法编译,因为没有类型来引入提供的同义词.但它很好:演示.这是什么意思,为什么编译?
这取决于缺少类型规范默认的事实int.
所以,你的陈述
typedef t;
Run Code Online (Sandbox Code Playgroud)
是相同的
typedef int t;
Run Code Online (Sandbox Code Playgroud)
如果有适当的警告级别,编译器会发出警告:
warning: type defaults to ‘int’ in declaration of ‘t’ [-Wimplicit-int]
typedef t;
^
Run Code Online (Sandbox Code Playgroud)
也就是说,不要依赖这种行为,"隐式int"规则已经过时了C99.