From: Andrew Crabtree Message-Id: <199705281343.AA017606995@typhoon.rose.hp.com> Subject: Re: djgpp bug To: komod AT csd DOT uch DOT gr (KOMODakis Nikolaos) Date: Wed, 28 May 1997 6:43:15 PDT Cc: djgpp AT delorie DOT com In-Reply-To: ; from "KOMODakis Nikolaos" at May 28, 97 2:34 pm Precedence: bulk > 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