delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/24/09:59:10

Date: Thu, 24 Jun 1999 15:55:38 +0200
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Message-Id: <199906241355.PAA13309@acp3bf.physik.rwth-aachen.de>
To: arg AT whangomatic DOT freeserve DOT co DOT uk (Andrew R. Gillett)
Cc: djgpp AT delorie DOT com
Subject: Re: Forgive me, for I have sinned without including math.h
Newsgroups: comp.os.msdos.djgpp
Organization: RWTH Aachen, III. physikalisches Institut B
X-Newsreader: TIN [version 1.2 PL2]
Reply-To: djgpp AT delorie DOT com

In article <MPG DOT 11db88b2dbac8f3298adc8 AT news DOT freeserve DOT net> you wrote:
> I just found a strange anomaly. I had two identical functions in 
> different programs using sin(). Each program gave significantly different 
> results. I eventually found that one of them wasn't including math.h. 

Had you asked gcc to help you while you were writing those programs,
the whole problem wouldn't probably have occured, in the first place.
It's not strictly an error, but highly unwise to compile any fresh
code without the use of the gcc options '-O2 -Wall', or even '-O2
-Wall -W'. And of course, you should pay attention to the warnings gcc
throws at you, in this mode of operation. 

Not all of the warnings will be signs of serious problems, but most of
them will. And it rarely hurts to remove the remaining 'superfluous'
ones by adding variable initialisations, casts, or making other small
adjustments to the code.  In the case of 'sin()' without #including
<math.h>, you'ld have got a warning: "calling function without a
prototype in sight" (or similar).

In a nutshell: the tools are there, right at your fingertips. You just
have to use them.

--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


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