From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: djgpp bug Date: Wed, 28 May 1997 12:46:02 -0700 Organization: Alcyone Systems Message-ID: <338C8B7A.4B4EB4C@alcyone.com> References: NNTP-Posting-Host: newton.alcyone.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 30 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk KOMODakis Nikolaos wrote: > > I have accidentally found the following bug in djgpp: > If you declare the same global (not static) variable in two different C > files, the compiler doesn't tell you anything (not even a warning). > However, it allocates the same space for the two definitions. > > I guess that this is a problem of the COFF format (that djgpp uses) and > the way this format handles global variables. This is not a DJGPP bug or COFF misfeature, this is an issue with fundamentally the way C works. Each module is compiled atomically -- that is, when compiling module A, the compiler has no knowledge of what it might or might not have compiled in a previous module. (gcc should make this clear because the program gets executed separate times in most makefiles.) Because of this lack of persistence, it has no way of knowing that the external variable it found shouldn't have been defined twice. It should give you an error when linking, though, so there's no problem. This same kind of behavior would be found in _any_ C compiler. -- Erik Max Francis, &tSftDotIotE / email / max AT alcyone DOT com Alcyone Systems / web / http://www.alcyone.com/max/ San Jose, California, United States / icbm / 37 20 07 N 121 53 38 W \ "Covenants without the sword / are but words." / Camden