【发布时间】:2018-04-28 20:43:12
【问题描述】:
为什么
//The type anything_at_all exists nowhere.
typedef struct anything_at_all lol;
编译没有错误,而
//The type anything_at_all_2 exists nowhere.
typedef anything_at_all_2 rofl;
产生错误?
结构体有什么特别之处?在某种程度上我很高兴它像这样工作,因为它允许我们创建不透明的结构。但最好能理解为什么它会起作用。
【问题讨论】:
-
因为
struct anything_at_all是一个不完整的类型。anything_at_all_2不是。 -
编译器无法确认
anything_at_all_2是什么类型的标识符(值或类型,如果是类型,那么是什么类型),而struct anything_at_all则非常清楚。
标签: c