From plummer at iarc.fr  Thu Jan  6 12:16:51 2005
From: plummer at iarc.fr (Martyn Plummer)
Date: Thu Jan  6 12:18:53 2005
Subject: [Rd] Standalone Mathlib, C++ and ISNAN()
In-Reply-To: <DB4A6959-5F60-11D9-97FA-000393D3D676@unsw.edu.au>
References: <77B2A8C4-5ED8-11D9-97FA-000393D3D676@unsw.edu.au>
	<Pine.A41.4.61b.0501050759060.100170@homer05.u.washington.edu>
	<C2214FA4-5F4F-11D9-97FA-000393D3D676@unsw.edu.au>
	<Pine.A41.4.61b.0501051149490.59084@homer03.u.washington.edu>
	<DB4A6959-5F60-11D9-97FA-000393D3D676@unsw.edu.au>
Message-ID: <1105010211.3643.5.camel@seurat>

On Thu, 2005-01-06 at 08:29 +1100, Bill Northcott wrote:
> On 06/01/2005, at 6:53 AM, Thomas Lumley wrote:
> >
> > I believe (with a little Googling) the suggested C++ approach is to 
> > use std::isnan if <cmath> is included.
> >
> I tried that too, but without any success.  I even tried 
> __gnu_cxx::isnan.
> 
> It was suggested by one of the gcc people, but I could find no 
> documentation about it.  The ISO C++ docs do not include isnan as a 
> symbol provided by cmath within the std namespace.  I looked at the gcc 
> source code and could see no reason why it should work.

I think the workaround is supposed to look like this:

#define _GLIBCPP_USE_C99 1
#include <cmath>
#undef _GLIBCPP_USE_C99
#include <iostream>

using __gnu_cxx::isnan;

I don't know whether this solves the problem on MacOs X but it is valid
on Linux.  But do you really want to write code that is specific to gcc?
I don't.

Martyn


[Rd] Standalone Mathlib, C++ and ISNAN()
Martyn Plummer