Question

I'm trying to make a global variable, initialized in my msh.c file as:

volatile sig_atomic_t sig_int = 0;

This alone seems to be fine. However if I go to my proto.h file(which is included in all the c files for this project), and type:

extern volatile sig_atomic_t sig_int;

It throws a bunch of errors:

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

How exactly do I make this variable global? Thanks.

Was it helpful?

Solution

Your proto.h file needs to include <signal.h> so that the sig_atomic_t type is defined, that's all.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top