Mail Archives: djgpp/1997/05/28/15:37:31
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 -