Mail Archives: djgpp/2000/01/24/17:59:25
Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> writes:
> On Mon, 17 Jan 2000, Andris Pavenis wrote:
>
> > Including $DJDIR/lib/../include/sys/version.h is a hack how to get
> > definitions of current DJGPP version automatically in. I still think
> > that best would be to force to include stdio.h when one needs version
> > definitions, but there were objections against such solution.
>
> The main objection is this: the ANSI Standard says that a program
> which doesn't include any header files should still have the same
> behavior as when it does.
How can this be?
Consider:
#include <math.h>
double my_sqrt(double d);
{
double x;
return sqrt(d);
}
If you don't include <math.h>, the implicit declaration of `sqrt' will
be used: `int sqrt();'. So the compiler will use the calling
conventions for an int-returning function instead of a double, and on
most platforms it'll be wrong. On x86, for instance, you'll get
whatever garbage was in %eax, casted to double. This is definitely
different behavior than when you do include <math.h>, when you get the
right answer.
Does ANSI really expect every platform to work some magic to make this
work anyhow? Are there any that actually do?
--
Nate Eldredge
neldredge AT hmc DOT edu
- Raw text -