This is the mail archive of the
mailing list for the Cygwin project.
Re: missing declaration for floorl
- From: Brian Dessent <brian at dessent dot net>
- To: cygwin at cygwin dot com
- Date: Wed, 01 Aug 2007 14:18:15 -0700
- Subject: Re: missing declaration for floorl
- References: <email@example.com>
- Reply-to: cygwin at cygwin dot com
Fred Hansen wrote:
> The random nubers package in http://www.agner.org/random/ uses function
> floorl. It is present in the cygwin g++ library
> (/lib/gcc/i686-pc-cygwin/3.4.4/libstdc++.a), but is not declared in any of
> the header files (cd /usr/include; grep -rI floorl). If I declare it:
> long double floorl(long double x);
> then I can call it, link it, and get the correct result.
> Should math.h be augmented with the declaration of floorl?
No. It's not a mistake that the definition is missing from math.h,
because Cygwin does not provide this function. libstdc++ is the C++
standard library, and in general it does not implement basic libc
functions like floorl, it relies on the target's C library
implementation for those. And in fact the floorl that is in libstdc++
is not a real implementation of floorl, it's just a stub:
floorl(long double x)
return floor((double) x);
The comment at the top of this file (libmath/stubs.c) even says:
/* For targets which do not have support for long double versions,
we use the crude approximation. We'll do better later. */
So it's clear that these functions are only provided as a last resort,
and they aren't even fully correct implementations either since they
just cast away the extra bits.
And even if you added a prototype to math.h for this crude floorl(),
linking would still fail on plain C source using the gcc driver, because
you do not link with libstdc++ unless you use g++. So it would still be
a broken implementation, but even more confusingly broken since it would
appear to support something that it doesn't.
No, the real problem is not that there are missing prototypes, it's that
actual long double support is missing.
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html