S
subramanian100in
Suppose I declare a global variable
int g;
in two different files say a.c which has main() and b.c
When I compile them to build an executable under gcc in Redhat Linux
with the command
gcc -std=c99 -pedantic -Wall -Wextra a.c b.c
there is no linker error.
I thought there should be linker error because of two definitions for
the same global variable.
Where am I going wrong ?
int g;
in two different files say a.c which has main() and b.c
When I compile them to build an executable under gcc in Redhat Linux
with the command
gcc -std=c99 -pedantic -Wall -Wextra a.c b.c
there is no linker error.
I thought there should be linker error because of two definitions for
the same global variable.
Where am I going wrong ?