1 /**************************************************************************
2 * compiler.h -- C++ Compiler Portability Macros
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 **************************************************************************/
23 * A set of defines to encapsulate compiler and platform differences.
24 * Please refer to the source code for full documentation on this file.
26 * This file is useful to set compiler-specific options in every file - for
27 * example, disabling warnings.
31 #ifndef _SG_COMPILER_H
32 #define _SG_COMPILER_H
35 * Helper macro SG_STRINGIZE:
36 * Converts the parameter X to a string after macro replacement
37 * on X has been performed.
39 #define SG_STRINGIZE(X) SG_DO_STRINGIZE(X)
40 #define SG_DO_STRINGIZE(X) #X
44 # error Time to upgrade. GNU compilers < 3.0 not supported
45 # elif (__GNUC__ == 3) && (__GNUC_MINOR__ < 4)
46 # warning GCC compilers prior to 3.4 are suspect
49 # define SG_COMPILER_STR "GNU C++ version " SG_STRINGIZE(__GNUC__) "." SG_STRINGIZE(__GNUC_MINOR__)
54 # define SG_COMPILER_STR "Kai C++ version " SG_STRINGIZE(__KCC_VERSION)
58 // Microsoft compilers.
61 # define bcopy(from, to, n) memcpy(to, from, n)
63 # if _MSC_VER >= 1200 // msvc++ 6.0 or greater
65 # define snprintf _snprintf
67 # define vsnprintf _vsnprintf
69 # define copysign _copysign
71 # pragma warning(disable: 4786) // identifier was truncated to '255' characters
72 # pragma warning(disable: 4244) // conversion from double to float
73 # pragma warning(disable: 4305) //
76 # error What version of MSVC++ is this?
79 # define SG_COMPILER_STR "Microsoft Visual C++ version " SG_STRINGIZE(_MSC_VER)
84 // Native SGI compilers
87 #if defined ( sgi ) && !defined( __GNUC__ )
88 # if (_COMPILER_VERSION < 740)
89 # error Need MipsPro 7.4.0 or higher now
92 #define SG_HAVE_NATIVE_SGI_COMPILERS
94 #pragma set woff 1001,1012,1014,1116,1155,1172,1174
95 #pragma set woff 1401,1460,1551,1552,1681
98 # pragma set woff 1682,3303
99 # pragma set woff 3624
102 # define SG_COMPILER_STR "SGI MipsPro compiler version " SG_STRINGIZE(_COMPILER_VERSION)
104 #endif // Native SGI compilers
108 # include <strings.h>
110 # if defined ( __cplusplus )
111 // typedef unsigned int size_t;
113 extern void *memmove(void *, const void *, size_t);
116 extern void *memmove(void *, const void *, size_t);
117 # endif // __cplusplus
119 # if !defined( __GNUC__ )
120 # define SG_COMPILER_STR "Sun compiler version " SG_STRINGIZE(__SUNPRO_CC)
126 // Intel C++ Compiler
128 #if defined(__ICC) || defined (__ECC)
129 # define SG_COMPILER_STR "Intel C++ version " SG_STRINGIZE(__ICC)
133 // Platform dependent gl.h and glut.h definitions
138 # if ( __GNUC__ > 3 ) || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 3 )
139 inline int (isnan)(double r) { return !(r <= 0 || r >= 0); }
141 // any C++ header file undefines isinf and isnan
142 // so this should be included before <iostream>
143 // the functions are STILL in libm (libSystem on mac os x)
144 extern "C" int (isnan)(double);
145 extern "C" int (isinf)(double);
148 inline int (isnan)(double r) { return !(r <= 0 || r >= 0); }
152 #if defined (__FreeBSD__)
153 # if __FreeBSD_version < 500000
155 inline int isnan(double r) { return !(r <= 0 || r >= 0); }
160 #if defined (__CYGWIN__)
161 # include <ieeefp.h> // isnan
166 // No user modifiable definitions beyond here.
169 #endif // _SG_COMPILER_H