Some shadow fixes.
Nathan Myers
ncm@cantrip.org
Thu May 18 17:24:00 GMT 2000
On Thu, May 18, 2000 at 12:36:21PM -0700, Steven King wrote:
> This patch fixes some typos that prevent compilation and adds some
> required symbols. Additionally, I've restructured the way cmath
> exposes the double precision routines, using a inline forwarding
> function instead of a using directive makes for better looking
> error messages. I'm somewhat of the opinion that all of the
> shadowed functions should be done this way.
>
> 2000-05-18 Steven King <sxking@uswest.net>
>
> * shadow/math.h: Add ::abs(float), ::abs(double) as inline
> forwardingcall to std::abs(float), std::abs(double);
> ...
> > //we cant use using ::std::abs; here
> > inline float abs (float __x) { return std::abs (__x); }
> > inline double abs (double __x) { return std::abs (__x); }
Unfortunately, the standard requires that the ::abs visible when you
include <math.h> be identically the same function as the std::abs.
it also defines. The same applies if somebody includes <cmath>
and you later include <math.h>, or vice versa.
In practice, this means you have to hide the extern "C" declaration
in a namespace somewhere, and define a single inline forwarding
function to expose in various namespaces. There are several examples
of this in the shadow headers already; it seems we must use the same
trick for the math functions too.
Note, though, that the C++ standard doesn't include the C99 extensions,
so any such have to be guarded with #ifdef __USE_C9X.
Nathan Myers
ncm at cantrip dot org
More information about the Libstdc++
mailing list