From owner-freebsd-current Sat Mar 30 18:50:42 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id SAA06072 for current-outgoing; Sat, 30 Mar 1996 18:50:42 -0800 (PST) Received: from cabri.obs-besancon.fr (cabri.obs-besancon.fr [193.52.184.3]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id SAA06062 for ; Sat, 30 Mar 1996 18:50:38 -0800 (PST) Received: by cabri.obs-besancon.fr (5.57/Ultrix3.0-C) id AA18217; Sun, 31 Mar 96 03:53:40 +0100 Date: Sun, 31 Mar 96 03:53:40 +0100 Message-Id: <9603310253.AA18217@cabri.obs-besancon.fr> From: Jean-Marc Zucconi To: regnauld@tetard.frmug.fr.net Cc: current@freebsd.org In-Reply-To: <199603301436.PAA13952@tetard.frmug.fr.net> (message from Philippe Regnauld on Sat, 30 Mar 1996 15:36:26 +0100 (MET)) Subject: Re: Weird atof() behavior X-Mailer: Emacs Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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 , gcc does NOT issue any sort of warning for > atof(). Example: > #include > 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 =============================================================================