On Sunday 24 October 2004 08:56, Peter Jay Salzman wrote:
> I'm trying to get one of my programs to compile and run on a 64bit alpha
> running Debian/unstable.
>
> gcc is generating "implicit declaration" errors (I'm using -Werror) for
> functions like ceill(), sqrtl(), logl(), etc.
>
> I always took <tgmath.h> to be declarations for math functions that work on
> any kind of data type, like a sqrt that returns a long double (named sqrtl)
> or a ceil that returns a float (named ceilf).
>
> But upon a little reading, I think I might be incorrect.
>
> Is the point of tgmath to allow us to use sqrt() for ANY floating point
> type and the compiler will take care of the details of calling the proper
> version of the function?
>
> If so, the compiler can certainly guess which math function we want to use,
> but in the snippet:
>
>
> long double ret;
> float arg;
>
> ret = sqrt(arg);
>
> would the compiler choose sqrtl() or sqrtf() as the backend to sqrt()?
It would choose sqrtf. tgmath.h defines sqrt as a macro so the type it chooses
will depend on its args. The result will be cast to the type of "ret", if that
is valid, otherwise there will be an error.
>
>
> Or was I originally correct in thinking that it's up to us to invoke which
> function we want explicitly, like:
>
> long double ret;
> long double arg;
>
> ret = sqrtl(arg);
Since sqrtl is not a macro no substitution will occur and you will get exactly
what you coded. tgmath.h does include math.h (and complx.h)
Richard Harke
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech