strange behaviour powl
Tue Jan 31 23:18:00 GMT 2006
David Vonka wrote:
> Note that the only difference is "1" instead of "K" on line 3.
> I compile by following command:
> gcc blan.c -lm
> In case A the answer of gcc is
> /cygdrive/c/Temp/ccEHzDhs.o:blan.c:(.text+0x30): undefined reference to
> collect2: ld gaf exit-status 1 terug
There is no need to ever use -lm under Cygwin because all math functions
are in the main cygwin1.dll. Specifying -lm is a no-op.
> In case B the program compiles without any problem and returns correct
> answer when run. Both programs compile when substituting "pow" for
> "powl". The switch "-lm" makes no difference(!), the result is exactly
> the same without it.
Cygwin does not provide an implementation of powl(). In case B the
compiler optimized away the call to the function because it recognised
that raising a number to the power of 1 does nothing.
More information about the Gcc-help