Article View: gnu.gcc.help
Article #42348Re: Bug in gcc, libc, or programmer?
From: Mark P. Nelson
Date: Wed, 13 Dec 1995 00:00
Date: Wed, 13 Dec 1995 00:00
68 lines
3257 bytes
3257 bytes
Therer's nothing wrong with the code; the problem is thinking that a Sun is
a standard development environment. You're linking code that expects libc
to be ANSI, and Sun's isn't.
Either don't use modern functions like strtod or fgetpos in your code, or
install the gnu libc on the Sun and link against that.
To see what you are linking against currently, compile your code like this:
gcc -v -Wall -ansi -pedantic quack.c -o quack
Which gives me output like this, and I'm sorry about the linelengths already,
O.K?
Reading specs from /vol/moby/moby_a/gnu/sun4_sunos4.1.3/lib/gcc-lib/sun4/2.7.0/specs
gcc version 2.7.0
/vol/moby/moby_a/gnu/sun4_sunos4.1.3/lib/gcc-lib/sun4/2.7.0/cpp -lang-c -v -undef -D__GNUC__=2 -D__GNUC_MINOR__=7 -trigraphs -$ -D__STRICT_ANSI__ -D__sparc__ -D__sun__ -D__unix__ -D__GCC_NEW_VARARGS__ -D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(bsd) -Acpu(sparc) -Amachine(sparc) -Wall -pedantic quack.c /tmp/cca11514.i
GNU CPP version 2.7.0 (sparc)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/vol/moby/moby_a/gnu/sun4_sunos4.1.3/sun4/include
/vol/moby/moby_a/gnu/sun4_sunos4.1.3/lib/gcc-lib/sun4/2.7.0/include
/usr/include
End of search list.
/vol/moby/moby_a/gnu/sun4_sunos4.1.3/lib/gcc-lib/sun4/2.7.0/cc1 /tmp/cca11514.i -quiet -dumpbase quack.c -Wall -pedantic -ansi -version -o /tmp/cca11514.s
GNU C version 2.7.0 (sparc) compiled by GNU C version 2.7.0.
quack.c: In function `main':
quack.c:9: warning: implicit declaration of function `strtod'
quack.c:13: warning: implicit declaration of function `printf'
as -o /tmp/cca115141.o /tmp/cca11514.s
/vol/moby/moby_a/gnu/sun4_sunos4.1.3/lib/gcc-lib/sun4/2.7.0/ld -e start -dc -dp -o quack /lib/crt0.o -L/vol/moby/moby_a/gnu/sun4_sunos4.1.3/lib/gcc-lib/sun4/2.7.0 -L/vol/moby/moby_a/gnu/sun4_sunos4.1.3/lib /tmp/cca115141.o -lgcc -lc -lgcc
taavo r (taavo@taavo1.roc.servtech.com) wrote:
: What is wrong with this piece of code?. The strtod()
: was breaking a program I had, but atof seems to work...
: #include <stdlib.h>
: #include <stdio.h>
: int main()
: {
: double dPi, dZero, dPi2;
: char szPi[]="3.14";
: dPi = strtod ( szPi, NULL);
: dPi2 = atof (szPi);
: dZero = dPi - dPi2;
: printf ("\nPi: %f Pi2: %f Zero: %f", dPi, dPi2, dZero);
: return 1;
: }
: when compiled and run on a gcc 263, SunOS 4.1.3, here
: is the (screwed up) output:
: $a.out
: $Pi: -134218664.000000 Pi2: 3.140000 Zero: -134218
: but it works flawlessly on gcc 272 on a linux.
: Is it a bugf in my program , in libc, or in gcc?
--
Mark P. Nelson
Programmer/Analyst II -- First you program, then you analyze.
Department of Integrative Biology, Thomson Laboratory
Technical Details
Message-ID:
<4anc71$a78@agate.berkeley.edu>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<30CE026D.380E7120@taavo1.roc.servtech.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,b762babb78f8c3a3 X-Google-Attributes: gid11318c,public From: mpn@biol.berkely.edu (Mark P. Nelson) Subject: Re: Bug in gcc, libc, or programmer? Date: 1995/12/13 Message-ID: <4anc71$a78@agate.berkeley.edu> X-Deja-AN: 121757936 references: <30CE026D.380E7120@taavo1.roc.servtech.com> organization: Dept. of Integrative Biology: Thomson Lab. reply-to: mpn@alleleb.biol.berkeley.edu newsgroups: gnu.gcc.help