delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/28/09:44:34

From: Andrew Crabtree <andrewc AT typhoon DOT rose DOT hp DOT com>
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: <Pine.SUN.3.96.970528142355.20590A-100000@gavdos.csd.uch.gr>; from "KOMODakis Nikolaos" at May 28, 97 2:34 pm

> 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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019