[vsipl++] [patch] RFA mercury's missing std::abs

Mark Mitchell mark at codesourcery.com
Fri Nov 11 17:38:58 UTC 2005


Stefan Seefeld wrote:
> Jules Bergmann wrote:
> 
>> This patch checks for missing std::abs overloads for float and double
>> at configure time.  If missing (and ::abs overloads exist),
>> VSIP_IMPL_FIX_MISSING_ABS is defined, which causes vsip::mag and
>> vsip::magsq to use a blend of vsip::abs and ::abs.
>>
>> This should be more robust than relying on the order of <cmath> and
>> <cstdlib> (which might break if users include standard headers before
>> including vsip headers -- something I tend to do).
>>
>> Comments?
> 
> 
> Since we now understand exactly what is going wrong (i.e. the
> 
> namespace std { using ::abs;}
> 
> line is issued before the relevant declarations have been seen),
> why don't we simply place such a using-directive close to our own
> inclusion of <cmath> ? That would have the exact same effect as
> including <cstdlib> after <cmath>, without relying on its header guards
> not being active.

As Jules said, I think this would be very dangerous; it might break
programs that otherwise work with Green Hills.  This is just an ugly
fact of trying to write portable software: compilers are broken and you
have to work around their problems.

-- 
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery.com
(916) 791-8304



More information about the vsipl++ mailing list