我正在尝试创建一个全局变量,在我的 msh.c 文件中初始化为:
volatile sig_atomic_t sig_int = 0;
仅此一项似乎还不错。但是,如果我转到我的 proto.h 文件(该文件包含在该项目的所有 c 文件中),然后键入:
extern volatile sig_atomic_t sig_int;
它抛出了一堆错误:
gcc -c -Wall msh.c arg_parse.c builtin.c expand.c
In file included from arg_parse.c:5:
proto.h:3: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘sig_int’
In file included from builtin.c:13:
proto.h:3: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘sig_int’
In file included from expand.c:11:
proto.h:3: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘sig_int’
make: *** [msh.o] Error 1
我究竟如何使这个变量成为全局变量?谢谢。