我正在阅读'The C Programming Language',并且遇到关于typedef struct的问题。该代码是这样的:struct typedef中的声明规则
typedef struct tnode *Treeptr;
typedef struct tnode { /* the tree node: */
char *word; /* points to the text */
int count; /* number of occurrences */
struct tnode *left; /* left child */
struct tnode *right; /* right child */
} Treenode;
通过我们写
typedef struct tnode *Treeptr;
TNODE仍尚未宣布的时间,但我们没有得到任何编译错误, 但是当我们改变上面的语句成:
typedef Treenode *Treeptr;
我们得到的编译错误:
error: parse error before '*' token
warning: data definition has no type or storage class
是什么导致差异? “结构tnode”不是“Treenode”吗?
您可能会发现[C标准的哪个部分允许此代码编译?](http://stackoverflow.com/questions/12200096/which-part-of-the-c-standard-allows-this-code C++标准是否认为这个头文件中有一个或两个'struct uperms_entry'类型?](http://stackoverflow.com/questions/11697705/does-the-c-standard-consider -that-one-or-two-struct-uperms-entry-typ)作为相关内容,但它们可能会超出你所在的级别。 –