1 #ifndef _2GEOM_ISNAN_H__
2 #define _2GEOM_ISNAN_H__
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
20 * the 2004 copyright for the code itself.
21 */
23 #include <math.h>
24 /* You might try changing the above to <cmath> if you have problems.
25 * Whether you use math.h or cmath, you may need to edit the .cpp file
26 * and/or other .h files to use the same header file.
27 */
29 #if defined(__isnan)
30 # define IS_NAN(_a) (__isnan(_a))
31 #elif defined(__APPLE__) && __GNUC__ == 3
32 # define IS_NAN(_a) (__isnan(_a)) /* MacOSX/Darwin definition < 10.4 */
33 #elif defined(WIN32) || defined(_isnan)
34 # define IS_NAN(_a) (_isnan(_a)) /* Win32 definition */
35 #elif defined(isnan) || defined(__FreeBSD__) || defined(__osf__)
36 # define IS_NAN(_a) (isnan(_a)) /* GNU definition */
37 #elif defined (SOLARIS_2_8) && __GNUC__ == 3 && __GNUC_MINOR__ == 2
38 # define IS_NAN(_a) (isnan(_a)) /* GNU definition */
39 #else
40 # define IS_NAN(_a) (std::isnan(_a))
41 #endif
42 /* If the above doesn't work, then try (a != a).
43 * Also, please report a bug as per http://www.inkscape.org/report_bugs.php,
44 * giving information about what platform and compiler version you're using.
45 */
48 #if defined(__isfinite)
49 # define IS_FINITE(_a) (__isfinite(_a))
50 #elif defined(__APPLE__) && __GNUC__ == 3
51 # define IS_FINITE(_a) (__isfinite(_a)) /* MacOSX/Darwin definition < 10.4 */
52 #elif defined(__sgi)
53 # define IS_FINITE(_a) (_isfinite(_a))
54 #elif defined(isfinite)
55 # define IS_FINITE(_a) (isfinite(_a))
56 #elif defined(__osf__)
57 # define IS_FINITE(_a) (finite(_a) && !IS_NAN(_a))
58 #elif defined (SOLARIS_2_8) && __GNUC__ == 3 && __GNUC_MINOR__ == 2
59 #include <ieeefp.h>
60 #define IS_FINITE(_a) (finite(_a) && !IS_NAN(_a))
61 #else
62 # define IS_FINITE(_a) (std::isfinite(_a))
63 #endif
64 /* If the above doesn't work, then try (finite(_a) && !IS_NAN(_a)) or
65 * (!IS_NAN((_a) - (_a))).
66 * Also, please report a bug as per http://www.inkscape.org/report_bugs.php,
67 * giving information about what platform and compiler version you're using.
68 */
71 #endif /* _2GEOM_ISNAN_H__ */
73 /*
74 Local Variables:
75 mode:c++
76 c-file-style:"stroustrup"
77 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
78 indent-tabs-mode:nil
79 fill-column:99
80 End:
81 */
82 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :