From bug-request at octave dot org Thu Dec 16 17:59:26 2004 Subject: Re: signbit on linux/gcc 3.2+ From: Orion Poplawski To: "John W. Eaton" CC: bug at octave dot org Date: Thu, 16 Dec 2004 17:49:34 -0600 John W. Eaton wrote: > That's fine, for systems using GCC and GNU libstdc++. But we can't > simply use > > #include > using std::signbit; > > on all systems, which is what I think your patch did. > > jwe Okay, here's another attempt. I'm leaving in the HAVE_SIGNBIT check because I suspect that is still necessary for __MINGW32__ (since it looks like it has the function but perhaps not the declaration). I've remove on the assumption that we are all C++ code. Other question would be whether to have the #error statement, or just get rid of the #else and not define lo_ieee_signbit and let other code complain. Does the following work on the sun? #include #include int main (void) { std::cerr << signbit (-1.0) << std::endl; return 0; } Just for fun, see http://osl.iu.edu/~tveldhui/papers/techniques/techniques01.html --- octave-2.1.64/configure.in.orig 2004-11-11 22:40:15.000000000 -0700 +++ octave-2.1.64/configure.in 2004-12-16 16:34:16.209266151 -0700 at @ -1153,6 +1153,7 @@ ;; *) AC_CHECK_FUNCS(finite isnan isinf copysign signbit) + AC_CHECK_DECLS(signbit,,,[#include ]) ;; esac --- octave-2.1.64/liboctave/lo-ieee.h.orig 2003-09-05 10:55:42.000000000 -0600 +++ octave-2.1.64/liboctave/lo-ieee.h 2004-12-16 16:34:01.509814447 -0700 at @ -24,6 +24,13 @@ #define octave_liboctave_ieee_h 1 +/* Use c++ signbit */ +#include +/* GNUC puts it in std:: */ +#ifdef __GNUC__ +using std::signbit; +#endif + #ifdef __cplusplus extern "C" { #endif at @ -72,7 +79,7 @@ #if defined (signbit) #define lo_ieee_signbit(x) signbit (x) -#elif defined (HAVE_SIGNBIT) +#elif defined (HAVE_DECL_SIGNBIT) || defined (HAVE_SIGNBIT) #if defined (__MINGW32__) extern int signbit (double); #endif at @ -82,7 +89,7 @@ #elif defined (HAVE_COPYSIGN) #define lo_ieee_signbit(x) (x < 0 || copysign (1.0, x) < 0) #else -#define lo_ieee_signbit(x) 0 +#error "No signbit definition?!" #endif #ifdef __cplusplus -- Orion Poplawski System Administrator 303-415-9701 x222 Colorado Research Associates/NWRA FAX: 303-415-9702 3380 Mitchell Lane, Boulder CO 80301 http://www.co-ra.com ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------