Boost logo

Boost :

From: Kevin Lynch (krlynch_at_[hidden])
Date: 2001-09-28 13:52:35

Eric Ford Wrote:

>> Kevin Lynch wrote:
>> C99 (not C89, and hence not ISO-C++) defines the "suffix functions"
>> (such as sinf for float arguments, sinl for long double, etc).
>> are therefore NOT part of the ISO-C++ standard, and I don't think
>> should be using them as the "implementation" for the template
>> for a standards compliant, portable "reference implementation". But
>> don't need them anyway, I don't think, since the standard overload
>> resolution mechanism should allow the compiler to pick the right
>> overloaded function.

> You may be right about what the standards specify. However with g++
> 2.95, it looks like there is no overloading for float sin(float x) or
> long double sin(long double x).

Yup, I discovered exactly the same thing last night when I was hacking
on the code .... what I said about the standards is correct, but the
real world is being problematic :-)

In the "3.0" version of the gcc ANSI C++ library (an "in progress"
version ships with the gcc-2.96 suite that ships with Redhat 7.1), if
you take a look in <cmath>, you'll find all the overload prototypes, but
they are commented out with a #if 0 as there don't appear to (yet)
be implementations of these functions. This same library, however, DOES
have implementations of the "suffix functions" from C99. (It gets
wierder on the x86 ... the implementations of all three functions, sinf,
sin, sinl for example, are identical assembly code in glibc ... not a
bit of difference that I could detect, meaning, I think, that the
assembly generated from these templates will be doing casting on the too
and from the fpu, even with the choice of the correct template :-(

> I suppose some preprocessor flags could allow it to use the *f and *l functions if they
> were avaliable, but that's not very elegant.

I agree on both counts, unfortunately. The right (interim)
implementation workaround is straightforward, I think: create at least
three preprocessor flags


(I'm not attached to the names). The correct combinations should do the
"right thing", which is pretty obvious, I think. I'm working on
implementing this stuff on your design as I mentioned in a previous
email. I still think that I can have it done by Monday (although I
don't guarantee that it will work :-)

Kevin Lynch				voice:	 (617) 353-6065
Physics Department			Fax: (617) 353-6062
Boston University			office:	 PRB-565
590 Commonwealth Ave.			e-mail:	 krlynch_at_[hidden]
Boston, MA 02215 USA

Boost list run by bdawes at, gregod at, cpdaniel at, john at