delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/28/15:37:31

From: Jeff Taylor <elric AT dcn DOT davis DOT ca DOT us>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: djgpp bug
Date: Wed, 28 May 1997 10:45:51 -0700
Organization: University of California, Davis
Lines: 20
Message-ID: <338C6F4F.70AE@dcn.davis.ca.us>
References: <Pine DOT SUN DOT 3 DOT 96 DOT 970528105752 DOT 17268A-100000 AT dia DOT csd DOT uch DOT gr>
NNTP-Posting-Host: dcn73.dcn.davis.ca.us
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

This is for backward compatibility.  In pre-ANSI C, external
declarations were very shaky and ill-defined.  What you have found was
the way it was expected to work.  The statement "int name;" was a
definition (i.e., the same as "extern int name;") in some compilers and
a declaration (with space allocation) in others.  "int name = 0;" was
the most portable way to force allocation.

Jeff

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

- Raw text -


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