Mail Archives: djgpp/2004/08/06/08:46:47
[F'up2 c.l.c, because the ball is safely back in their playing field.]
In comp.os.msdos.djgpp CBFalconer <cbfalconer AT yahoo DOT com> wrote:
> I agree with you, provided you use -ansi -pedantic.
You don't need -pedantic in this case. What you need is the effect of
-ansi turning off all extensions present in the compiler's runtime
library, compared to the C standard. In other words, you need a clean
namespace for the above program to reliably print zero, and that's
what -ansi is meant to give you.
On a more relaxed note, you can ask gcc to warn you in situations like
this, while still keeping the full functionality of the standard libc
intact, by using the -fno-common option. In terms of the standard:
-fno-common turns off the usual Unix linkers' extension of allowing
tentative definitions to be resolved across the entire program, not
just individual translation units.
This problem is actually a comp.lang.c FAQ, and addressed in the C
FAQ. Usually it happens with the name 'index', which exists in Unix
libc, is not an ANSI/ISO standard C library function, but is *very*
tempting to use as the name of some object in your own source code,
until you run into this the first time. Go figure.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -