Mail Archives: djgpp/1997/05/28/09:44:34
> The two files (that contain the same global variable) are linked to an
> executable and are not just compiled.
>
> If you compile and link these two files, you will get no error or warning
> from djgpp.
I can't say for sure what is going on here but I have seen something very
similar out of gcc960. The problem is that the linker just never wants to
look in bss for references.
In your case, if 1 or both of the defines for defined_twice is
unitialized (both for your example), you will not get a multiple
defined symbol error from the linker. Now, if you initialize both
of them (int defined_twice = 0;, int defined_twice = 1), then
you will get a linker error.
I believe that this may be expected behaviour actually (really not sure
here), with the way gcc marks symbols in the coff file they are defined
to be removed when redefined.
The trick is to just initialize your globals.
Andrew
- Raw text -