Adaptagrams
isnan.h
1 /*
2  * vim: ts=4 sw=4 et tw=0 wm=0
3  *
4  * libvpsc - A solver for the problem of Variable Placement with
5  * Separation Constraints.
6  *
7  * Copyright (C) 2005-2008 Monash University
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  * See the file LICENSE.LGPL distributed with the library.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18  *
19 */
20 
21 #ifndef VPSC_ISNAN_H
22 #define VPSC_ISNAN_H
23 
24 /*
25  * Temporary fix for various misdefinitions of isnan().
26  * isnan() is becoming undef'd in some .h files.
27  * #include this last in your .cpp file to get it right.
28  *
29  * The problem is that isnan and isfinite are part of C99 but aren't part of
30  * the C++ standard (which predates C99).
31  *
32  * Authors:
33  * Inkscape groupies and obsessive-compulsives
34  *
35  * Copyright (C) 2004 authors
36  *
37  * Released under GNU LGPL, read the file 'LICENSE' for more information
38  *
39  * 2005 modification hereby placed in public domain. Probably supercedes
40  * the 2004 copyright for the code itself.
41  */
42 
43 #include <cmath>
44 #include <cfloat>
45 
46 #if defined(__isnan)
47 # define isNaN(_a) (__isnan(_a)) /* MacOSX/Darwin definition < 10.4 */
48 #elif defined(WIN32) || defined(_isnan)
49 # define isNaN(_a) (_isnan(_a)) /* Win32 definition */
50 #elif defined(isnan) || defined(__FreeBSD__)
51 # define isNaN(_a) (isnan(_a)) /* GNU definition */
52 #else
53 # define isNaN(_a) (std::isnan(_a))
54 #endif
55 /* If the above doesn't work, then try (a != a).
56  * Also, please report a bug as per http://www.inkscape.org/report_bugs.php,
57  * giving information about what platform and compiler version you're using.
58  */
59 
60 
61 #if defined(__isfinite)
62 # define isFinite(_a) (__isfinite(_a)) /* MacOSX/Darwin definition < 10.4 */
63 #elif defined(isfinite)
64 # define isFinite(_a) (isfinite(_a))
65 #else
66 # define isFinite(_a) (std::isfinite(_a))
67 #endif
68 /* If the above doesn't work, then try (finite(_a) && !isNaN(_a)) or (!isNaN((_a) - (_a))).
69  * Also, please report a bug as per http://www.inkscape.org/report_bugs.php,
70  * giving information about what platform and compiler version you're using.
71  */
72 
73 
74 #endif /* VPSC_ISNAN_H */