delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/24/17:59:25

From: Nate Eldredge <neldredge AT hmc DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: make depend
Date: 24 Jan 2000 13:08:25 -0800
Organization: InterWorld Communications
Lines: 40
Message-ID: <83u2k3kwja.fsf@mercury.st.hmc.edu>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1000118095433 DOT 3041E-100000 AT is>
NNTP-Posting-Host: mercury.st.hmc.edu
Mime-Version: 1.0
X-Trace: nntp1.interworld.net 948748215 94644 134.173.45.219 (24 Jan 2000 21:10:15 GMT)
X-Complaints-To: usenet AT nntp1 DOT interworld DOT net
NNTP-Posting-Date: 24 Jan 2000 21:10:15 GMT
User-Agent: Gnus/5.0802 (Gnus v5.8.2) Emacs/20.5
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


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