I'm reading 'The C Programming Language' and encountered a problem about typedef of struct. The code is like this:
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;
By the time we write
typedef struct tnode *Treeptr;
tnode is still not declared yet, but we don't get any compilation error, but when we change the statement above into:
typedef Treenode *Treeptr;
We get compilation error:
error: parse error before '*' token
warning: data definition has no type or storage class
What causes the difference? Isn't "struct tnode" the same as "Treenode"?