Why am I getting this error: “data definition has no type or storage class”?
问题 #include <stdio.h> #include <stdlib.h> struct NODE { char* name; int val; struct NODE* next; }; typedef struct NODE Node; Node *head, *tail; head = (Node*) malloc( sizeof( Node ) ); //line 21 And I compiling like this: cc -g -c -o file.tab.o file.tab.c I'm getting this error message: file.y:21:1 warning: data definition has no type or storage class [enabled by default] 回答1: It looks like the line head = (Node*) malloc( sizeof( Node ) ); //line 21 is outside the main() function. You can't do