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 * Here is a summary of what this file does.
28 * (1) Defines macros for some STL includes which may be affected
29 * by file name length limitations.
31 * (2) Defines macros for some features not supported by all C++ compilers.
33 * (3) Defines 'explicit' as a null macro if the compiler doesn't support
34 * the explicit keyword.
36 * (4) Defines 'typename' as a null macro if the compiler doesn't support
37 * the typename keyword.
39 * (5) Defines bool, true and false if the compiler doesn't do so.
41 * (6) Defines SG_EXPLICIT_FUNCTION_TMPL_ARGS if the compiler
42 * supports calling a function template by providing its template
43 * arguments explicitly.
45 * (7) Defines SG_NEED_AUTO_PTR if STL doesn't provide auto_ptr<>.
47 * (8) Defines SG_NO_ARROW_OPERATOR if the compiler is unable
48 * to support operator->() for iterators.
50 * (9) Defines SG_USE_EXCEPTIONS if the compiler supports exceptions.
51 * Note: no FlightGear code uses exceptions.
53 * (10) Define SG_NAMESPACES if the compiler supports namespaces.
55 * (11) SG_MATH_FN_IN_NAMESPACE_STD -- not used??
57 * (12) Define SG_HAVE_STD if std namespace is supported.
59 * (13) Defines SG_CLASS_PARTIAL_SPECIALIZATION if the compiler
60 * supports partial specialization of class templates.
62 * (14) Defines SG_HAVE_STD_INCLUDES to use ISO C++ Standard headers.
64 * (15) Defines SG_HAVE_STREAMBUF if <streambuf> of <streambuf.h> are present.
68 #ifndef _SG_COMPILER_H
69 #define _SG_COMPILER_H
72 * Helper macro SG_STRINGIZE:
73 * Converts the parameter X to a string after macro replacement
74 * on X has been performed.
76 #define SG_STRINGIZE(X) SG_DO_STRINGIZE(X)
77 #define SG_DO_STRINGIZE(X) #X
82 # define SG_EXPLICIT_FUNCTION_TMPL_ARGS
83 # define SG_NEED_AUTO_PTR
84 # define SG_MEMBER_TEMPLATES
85 # define SG_NAMESPACES
87 # define SG_HAVE_STREAMBUF
88 # define SG_CLASS_PARTIAL_SPECIALIZATION
89 # define SG_HAVE_STD_INCLUDES
91 # define STL_ALGORITHM <algorithm>
92 # define STL_FUNCTIONAL <functional>
93 # define STL_IOMANIP <iomanip>
94 # define STL_IOSTREAM <iostream>
95 # define STL_ITERATOR <iterator>
96 # define STL_FSTREAM <fstream>
97 # define STL_STDEXCEPT <stdexcept>
98 # define STL_STRING <string>
99 # define STL_STRSTREAM <strstream>
101 # error Time to upgrade. GNU compilers < 3.0 not supported
104 # define SG_COMPILER_STR "GNU C++ version " SG_STRINGIZE(__GNUC__) "." SG_STRINGIZE(__GNUC_MINOR__)
111 # define SG_NAMESPACES
113 # define SG_HAVE_STREAMBUF
114 # define SG_HAVE_TRAITS
115 # define SG_HAVE_STD_INCLUDES
117 # define STL_ALGORITHM <algorithm>
118 # define STL_FUNCTIONAL <functional>
119 # define STL_IOMANIP <iomanip>
120 # define STL_IOSTREAM <iostream>
121 # define STL_ITERATOR <iterator>
122 # define STL_FSTREAM <fstream>
123 # define STL_STDEXCEPT <stdexcept>
124 # define STL_STRING <string>
125 # define STL_STRSTREAM <strstream>
127 # define SG_COMPILER_STR "Kai C++ version " SG_STRINGIZE(__KCC_VERSION)
132 // Microsoft compilers.
135 # define bcopy(from, to, n) memcpy(to, from, n)
136 # define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
138 # if _MSC_VER >= 1200 // msvc++ 6.0 or greater
139 # define SG_NAMESPACES
141 # define SG_HAVE_STD_INCLUDES
142 # define SG_HAVE_STREAMBUF
144 # define STL_ALGORITHM <algorithm>
145 # define STL_FUNCTIONAL <functional>
146 # define STL_IOMANIP <iomanip>
147 # define STL_IOSTREAM <iostream>
148 # define STL_ITERATOR <iterator>
149 # define STL_FSTREAM <fstream>
150 # define STL_STDEXCEPT <stdexcept>
151 # define STL_STRING <string>
152 # define STL_STRSTREAM <strstream>
154 # define isnan _isnan
155 # define snprintf _snprintf
156 # define copysign _copysign
158 # pragma warning(disable: 4786) // identifier was truncated to '255' characters
159 # pragma warning(disable: 4244) // conversion from double to float
160 # pragma warning(disable: 4305) //
163 # error What version of MSVC++ is this?
166 # define SG_COMPILER_STR "Microsoft Visual C++ version " SG_STRINGIZE(_MSC_VER)
171 // Native SGI compilers
174 #if defined ( sgi ) && !defined( __GNUC__ )
175 # define SG_HAVE_NATIVE_SGI_COMPILERS
177 # define SG_EXPLICIT_FUNCTION_TMPL_ARGS
178 # define SG_CLASS_PARTIAL_SPECIALIZATION
179 # define SG_NEED_AUTO_PTR
180 # define SG_MEMBER_TEMPLATES
181 # define SG_NAMESPACES
183 # define SG_HAVE_STREAMBUF
184 # define SG_HAVE_TRAITS
185 # define SG_HAVE_STD_INCLUDES
187 # define STL_ALGORITHM <algorithm>
188 # define STL_FUNCTIONAL <functional>
189 # define STL_IOMANIP <iomanip>
190 # define STL_IOSTREAM <iostream>
191 # define STL_ITERATOR <iterator>
192 # define STL_FSTREAM <fstream>
193 # define STL_STDEXCEPT <stdexcept>
194 #if (_COMPILER_VERSION < 740)
195 # define STL_STRING <irix_string>
197 # define STL_STRING <string>
199 # define STL_STRSTREAM <strstream>
201 #pragma set woff 1001,1012,1014,1116,1155,1172,1174
202 #pragma set woff 1401,1460,1551,1552,1681
205 #pragma set woff 1682,3303
206 #if (_COMPILER_VERSION >= 740)
207 # pragma set woff 3624
211 # define SG_COMPILER_STR "SGI MipsPro compiler version " SG_STRINGIZE(_COMPILER_VERSION)
213 #endif // Native SGI compilers
217 # include <strings.h>
219 # if defined ( __cplusplus )
220 // typedef unsigned int size_t;
222 extern void *memmove(void *, const void *, size_t);
225 extern void *memmove(void *, const void *, size_t);
226 # endif // __cplusplus
228 # if !defined( __GNUC__ )
229 # define SG_COMPILER_STR "Sun compiler version " SG_STRINGIZE(__SUNPRO_CC)
235 // Intel C++ Compiler
237 #if defined(__ICC) || defined (__ECC)
238 # define SG_NAMESPACES
240 # define SG_HAVE_STREAMBUF
241 # define SG_HAVE_TRAITS
242 # define SG_HAVE_STD_INCLUDES
244 # define STL_ALGORITHM <algorithm>
245 # define STL_FUNCTIONAL <functional>
246 # define STL_IOMANIP <iomanip>
247 # define STL_IOSTREAM <iostream>
248 # define STL_ITERATOR <iterator>
249 # define STL_FSTREAM <fstream>
250 # define STL_STDEXCEPT <stdexcept>
251 # define STL_STRING <string>
252 # define STL_STRSTREAM <strstream>
254 # define SG_COMPILER_STR "Intel C++ version " SG_STRINGIZE(__ICC)
259 // Platform dependent gl.h and glut.h definitions
263 # define SG_GL_H <OpenGL/gl.h>
264 # define SG_GLX_H <AGL/agl.h>
265 # define SG_GLU_H <OpenGL/glu.h>
266 # define SG_GLEXT_H <OpenGL/glext.h>
267 # define SG_GLUT_H <GLUT/glut.h>
270 inline int (isnan)(double r) { return !(r <= 0 || r >= 0); }
272 # define SG_GL_H <GL/gl.h>
273 # define SG_GLX_H <GL/glx.h>
274 # define SG_GLU_H <GL/glu.h>
275 # define SG_GLEXT_H <GL/glext.h>
276 # define SG_GLUT_H <GL/glut.h>
281 // No user modifiable definitions beyond here.
284 #ifdef SG_NEED_EXPLICIT
288 #ifdef SG_NEED_TYPENAME
292 #ifdef SG_NEED_MUTABLE
302 #ifdef SG_EXPLICIT_FUNCTION_TMPL_ARGS
303 # define SG_NULL_TMPL_ARGS <>
305 # define SG_NULL_TMPL_ARGS
308 #ifdef SG_CLASS_PARTIAL_SPECIALIZATION
309 # define SG_TEMPLATE_NULL template<>
311 # define SG_TEMPLATE_NULL
314 // SG_NO_NAMESPACES is a hook so that users can disable namespaces
315 // without having to edit library headers.
316 #if defined(SG_NAMESPACES) && !defined(SG_NO_NAMESPACES)
317 # define SG_NAMESPACE(X) namespace X {
318 # define SG_NAMESPACE_END }
319 # define SG_USING_NAMESPACE(X) using namespace X
321 # define SG_NAMESPACE(X)
322 # define SG_NAMESPACE_END
323 # define SG_USING_NAMESPACE(X)
326 /** \def SG_USING_STD(x)
327 * Expands to using std::x if SG_HAVE_STD is defined
330 # define SG_USING_STD(X) using std::X
333 # define SG_USING_STD(X)
337 #endif // _SG_COMPILER_H