1 #ifndef __ISNAN_H__ 2 #define __ISNAN_H__ 3 4 /* 5 * Temporary fix for various misdefinitions of isnan(). 6 * isnan() is becoming undef'd in some .h files. 7 * #include this last in your .cpp file to get it right. 8 * 9 * The problem is that isnan and isfinite are part of C99 but aren't part of 10 * the C++ standard (which predates C99). 11 * 12 * Authors: 13 * Inkscape groupies and obsessive-compulsives 14 * 15 * Copyright (C) 2004 authors 16 * 17 * Released under GNU GPL, read the file 'COPYING' for more information 18 * 19 * 2005 modification hereby placed in public domain. Probably supercedes the 2004 copyright 20 * for the code itself. 21 */ 22 23 #include <cmath> 24 #include <float.h> 25 /* You might try changing the above to <cmath> if you have problems. 26 * Whether you use math.h or cmath, you may need to edit the .cpp file 27 * and/or other .h files to use the same header file. 28 */ 29 30 #if defined(__isnan) 31 # define is_nan(_a) (__isnan(_a)) 32 #elif defined(__APPLE__) && __GNUC__ == 3 33 # define is_nan(_a) (__isnan(_a)) /* MacOSX/Darwin definition < 10.4 */ 34 #elif defined(WIN32) || defined(_isnan) 35 # define is_nan(_a) (_isnan(_a)) /* Win32 definition */ 36 #elif defined(isnan) || defined(__FreeBSD__) 37 # define is_nan(_a) (isnan(_a)) /* GNU definition */ 38 #else 39 # define is_nan(_a) (std::isnan(_a)) 40 #endif 41 /* If the above doesn't work, then try (a != a). 42 * Also, please report a bug as per http://www.inkscape.org/report_bugs.php, 43 * giving information about what platform and compiler version you're using. 44 */ 45 46 47 #if defined(__isfinite) 48 # define is_finite(_a) (__isfinite(_a)) 49 #elif defined(__APPLE__) && __GNUC__ == 3 50 # define is_finite(_a) (__isfinite(_a)) /* MacOSX/Darwin definition < 10.4 */ 51 #elif defined(isfinite) 52 # define is_finite(_a) (isfinite(_a)) 53 #elif defined(_MSC_VER) 54 # define is_finite(_a) (_finite(_a) && !_isnan(_a)) 55 #else 56 # define is_finite(_a) (std::isfinite(_a)) 57 #endif 58 /* If the above doesn't work, then try (finite(_a) && !isNaN(_a)) or (!isNaN((_a) - (_a))). 59 * Also, please report a bug as per http://www.inkscape.org/report_bugs.php, 60 * giving information about what platform and compiler version you're using. 61 */ 62 63 64 #endif /* __ISNAN_H__ */ 65