Date: Sun, 31 Mar 96 03:53:40 +0100 From: Jean-Marc Zucconi <jmz@cabri.obs-besancon.fr> To: regnauld@tetard.frmug.fr.net Cc: current@freebsd.org Subject: Re: Weird atof() behavior Message-ID: <9603310253.AA18217@cabri.obs-besancon.fr> In-Reply-To: <199603301436.PAA13952@tetard.frmug.fr.net> (message from Philippe Regnauld on Sat, 30 Mar 1996 15:36:26 %2B0100 (MET))
next in thread | previous in thread | raw e-mail | index | archive | help
This is the correct behavior: non declared functions are assumed returning int. You have to tell the compiler that atof() returns a float. Jean-Marc >>>>> Philippe Regnauld writes: > Hi, > A friend of mine has had some problems with Rayshade running on > 2.0.5 (GCC 2.6.3) -- it appeared that atof() systematically > returned bogus values in certain conditions: if you omit to specify > #include <stdlib.h>, gcc does NOT issue any sort of warning for > atof(). Example: > #include <stdio.h> > main() > { > foo* char="3.1415926"; > float bar=atof(foo); > printf("%f\n",bar); > } > Here's the output: > -7.000000 > This is obviously a GCC related problem (I've got the same results > with current), as testing with 2.5.8 showed no problems. It seems > that the value from is cast to a double, then cast to an int. > The warning does show up with -Wall: > atof.c:5: warning: implicit declaration of function `atof' > -- Phil > -- > - [ regnauld@tetard.frmug.fr.net / +48.8N+2.3E / +33 1 4507 9391 / Sol 3 ] - > - [ regnauld@freenix.fr / FreeBSD 2.x / ] - > "Le schtroumpf est ` l'homme ce que le bleu est au billard" - F.Berjon _____________________________________________________________________________ Jean-Marc Zucconi Observatoire de Besancon F 25010 Besancon cedex PGP Key: finger jmz@cabri.obs-besancon.fr =============================================================================
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9603310253.AA18217>