Mail Archives: djgpp/2001/05/09/02:16:38
Hans-Bernhard Broeker wrote:
>
> Florent Georges <darkman_spam AT yahoo DOT fr> wrote:
>
> > In a first time, I prefer to think that it's a bug in my install,
> > instead in gcc, but it's quite strange.
>
> Neither of these. It's a usage error.
>
> The function you're using, nextafterf(), is not in the ANSI
> standardized subset of library functions, and thus its declaration is
> turned invisible in gcc -ansi mode. Adding -O2 -Wall flags to your
> compile line would have given you a hint in that direction, warning
> about an "implicit declaration of function `nextafterf'".
>
> I.e.: this program of yours cannot be compiled by a strict ANSI C
> compiler like 'gcc -ansi'.
Actually, it can be - he DID compile and link it.
The problem is that the compiler never saw the prototype, so it assumes
all arguments are ints and therefore it will cast everything you pass to
it to int, which is definitely not what you want.
If you add a prototype for nextafterf to your .c file, I expect it will
behave correctly whether you use -ansi or not.
--
Tim Van Holder - Falcon Software N.V.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
This message was posted using plain text. I do not endorse any
products or services that may be hyperlinked to this message.
- Raw text -