Re: Removing GCC compiler warnings from fabsf(), sqrtf()...
From: Kevin Goodsell (usenet1.spamfree.fusion_at_neverbox.com)
Date: 01/02/04
- Next message: Kevin Goodsell: "Re: Removing GCC compiler warnings from fabsf(), sqrtf()..."
- Previous message: Kevin Goodsell: "Re: Vexing GCC warnings: "assignment discards qualifiers from pointer target type""
- In reply to: Charlie Zender: "Removing GCC compiler warnings from fabsf(), sqrtf()..."
- Next in thread: Kevin Goodsell: "Re: Removing GCC compiler warnings from fabsf(), sqrtf()..."
- Reply: Kevin Goodsell: "Re: Removing GCC compiler warnings from fabsf(), sqrtf()..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 02 Jan 2004 22:42:38 GMT
Charlie Zender wrote:
> Hi,
>
> First, this may be a GCC or Linux-specific problem, I'm not sure.
>
> I am unable to compile a large body of code with extremely pedantic
> compile time checks activate, so that warnings cause errors.
> With GCC 3.3.1, I do this with
>
> gcc -I/usr/local/include -g -O2 -std=c99 -pedantic -pedantic
> -D_BSD_SOURCE -Wall -Wunused -W -Wmissing-prototypes -Wconversion
> -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings
> bug.c -o bug -lm
This appears to be a gcc issue, not a C issue, which makes it off-topic
in comp.lang.c.
>
> (This is basically what GSL recommendsd for scientific codes.)
>
> The current problem I have is that the following code (bug.c)
>
> #include <stdio.h>
> #include <math.h>
> int main()
> {
> /* float fabsf(float); */
> float foo,bar=-9;
> foo=fabsf(bar);
> fprintf(stdout,"foo = %g\n",foo);
> }
>
> produces this warning:
>
> bug.c:7: warning: passing arg 1 of `fabsf' as `float' rather than
> `double' due to prototype
This warning appears to be a result of the -Wconversion option. You
should probably read up on what the options you are using do.
-Wconversion doesn't look like a good one to use in general (and may be
completely useless in c99 mode).
>
> _regardless_ of whether the correct fabsf() prototype
> (float fabsf(float);) is commented out or not.
The correct prototype is in <math.h>. You should almost never provide
prototypes for standard functions.
> Yes, my GNU/Linux system does have fabsf() etc. in libm.a.
> Yes, the intrinsics powf(), fabsf(), sqrtf()... cause the same warning.
>
> 1. How do I use powf(), fabsf(), sqrtf() etc. with causing compiler
> warnings with the above compiler switches?
That would seem to be impossible. -Wconversion will result in a warning
for absolutely any code that calls a function that takes a 'float' (or
'short' or 'char'), if I understand correctly.
-Kevin
-- My email address is valid, but changes periodically. To contact me please use the address from a recent posting.
- Next message: Kevin Goodsell: "Re: Removing GCC compiler warnings from fabsf(), sqrtf()..."
- Previous message: Kevin Goodsell: "Re: Vexing GCC warnings: "assignment discards qualifiers from pointer target type""
- In reply to: Charlie Zender: "Removing GCC compiler warnings from fabsf(), sqrtf()..."
- Next in thread: Kevin Goodsell: "Re: Removing GCC compiler warnings from fabsf(), sqrtf()..."
- Reply: Kevin Goodsell: "Re: Removing GCC compiler warnings from fabsf(), sqrtf()..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|