l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
April 21: Google Glass
Next Installfest:
TBD
Latest News:
Mar. 18: Google Glass at LUGOD's April meeting
Page last updated:
2004 Oct 24 19:19

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
[vox-tech] C99 functions - what does "type generic" really mean?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vox-tech] C99 functions - what does "type generic" really mean?



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()?


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);

Pete
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Appahost Applications
For a significant contribution towards our projector, and a generous donation to allow us to continue meeting at the Davis Library.