1 /**************************************************************************
2 * compiler.h -- C++ Compiler Portability Macros
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
19 **************************************************************************/
24 // What this file does.
25 // (1) Defines macros for some STL includes which may be affected
26 // by file name length limitations.
27 // (2) Defines macros for some features not supported by all C++ compilers.
28 // (3) Defines 'explicit' as a null macro if the compiler doesn't support
29 // the explicit keyword.
30 // (4) Defines 'typename' as a null macro if the compiler doesn't support
31 // the typename keyword.
32 // (5) Defines bool, true and false if the compiler doesn't do so.
33 // (6) Defines FG_EXPLICIT_FUNCTION_TMPL_ARGS if the compiler
34 // supports calling a function template by providing its template
35 // arguments explicitly.
36 // (7) Defines FG_NEED_AUTO_PTR if STL doesn't provide auto_ptr<>.
37 // (8) Defines FG_NO_ARROW_OPERATOR if the compiler is unable
38 // to support operator->() for iterators.
39 // (9) Defines FG_USE_EXCEPTIONS if the compiler supports exceptions.
40 // Note: no FlightGear code uses exceptions.
41 // (10) Define FG_NAMESPACES if the compiler supports namespaces.
42 // (11) FG_MATH_FN_IN_NAMESPACE_STD -- not used??
43 // (12) Define FG_HAVE_STD if std namespace is supported.
44 // (13) Defines FG_CLASS_PARTIAL_SPECIALIZATION if the compiler
45 // supports partial specialization of class templates.
46 // (14) Defines FG_HAVE_STD_INCLUDES to use ISO C++ Standard headers.
47 // (15) Defines FG_HAVE_STREAMBUF if <streambuf> of <streambuf.h> are present.
48 // (16) Define FG_MATH_EXCEPTION_CLASH if math.h defines an exception class
49 // that clashes with the one defined in <stdexcept>.
53 # if __GNUC_MINOR__ < 8
56 # define STL_ALGORITHM <algorithm>
57 # define STL_FUNCTIONAL <functional>
58 # define STL_IOMANIP <iomanip.h>
59 # define STL_IOSTREAM <iostream.h>
60 # define STL_FSTREAM <fstream.h>
61 # define STL_STDEXCEPT <stdexcept>
62 # define STL_STRING <string>
63 # define STL_STRSTREAM <strstream.h>
65 # define FG_NEED_AUTO_PTR
66 # define FG_NO_DEFAULT_TEMPLATE_ARGS
67 # define FG_INCOMPLETE_FUNCTIONAL
68 # define FG_NO_ARROW_OPERATOR
70 # elif __GNUC_MINOR__ >= 8
72 // g++-2.8.x and egcs-1.x
73 # define FG_EXPLICIT_FUNCTION_TMPL_ARGS
74 # define FG_NEED_AUTO_PTR
75 # define FG_MEMBER_TEMPLATES
76 # define FG_NAMESPACES
78 # define FG_HAVE_STREAMBUF
79 # define FG_CLASS_PARTIAL_SPECIALIZATION
81 # define STL_ALGORITHM <algorithm>
82 # define STL_FUNCTIONAL <functional>
83 # define STL_IOMANIP <iomanip>
84 # define STL_IOSTREAM <iostream>
85 # define STL_FSTREAM <fstream>
86 # define STL_STDEXCEPT <stdexcept>
87 # define STL_STRING <string>
88 # define STL_STRSTREAM <strstream>
92 # error Time to upgrade. GNU compilers < 2.7 not supported
99 #if defined(__MWERKS__)
101 CodeWarrior compiler from Metrowerks, Inc.
103 # define FG_HAVE_TRAITS
104 # define FG_HAVE_STD_INCLUDES
106 # define FG_NAMESPACES
108 # define STL_ALGORITHM <algorithm>
109 # define STL_FUNCTIONAL <functional>
110 # define STL_IOMANIP <iomanip>
111 # define STL_IOSTREAM <iostream>
112 # define STL_FSTREAM <fstream>
113 # define STL_STDEXCEPT <stdexcept>
114 # define STL_STRING <string>
117 # define bcopy(from, to, n) memcpy(to, from, n)
119 // -rp- please use FG_MEM_COPY everywhere !
120 # define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
122 // -dw- currently used glut has no game mode stuff
123 # define GLUT_WRONG_VERSION
127 // Microsoft compilers.
130 # define bcopy(from, to, n) memcpy(to, from, n)
131 # define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
133 # if _MSC_VER == 1200 // msvc++ 6.0
134 # define FG_NAMESPACES
136 # define FG_HAVE_STD_INCLUDES
137 # define FG_HAVE_STREAMBUF
139 # define STL_ALGORITHM <algorithm>
140 # define STL_FUNCTIONAL <functional>
141 # define STL_IOMANIP <iomanip>
142 # define STL_IOSTREAM <iostream>
143 # define STL_FSTREAM <fstream>
144 # define STL_STDEXCEPT <stdexcept>
145 # define STL_STRING <string>
146 # define STL_STRSTREAM <strstream>
148 # pragma warning(disable: 4786) // identifier was truncated to '255' characters
149 # pragma warning(disable: 4244) // conversion from double to float
150 # pragma warning(disable: 4305) //
152 # elif _MSC_VER == 1100 // msvc++ 5.0
153 # define NEEDNAMESPACESTD
154 # define FG_NAMESPACES
156 # define FG_HAVE_STD_INCLUDES
157 # define FG_HAVE_STREAMBUF
159 # define STL_ALGORITHM <algorithm>
160 # define STL_FUNCTIONAL <functional>
161 # define STL_IOMANIP <iomanip>
162 # define STL_IOSTREAM <iostream>
163 # define STL_FSTREAM <fstream>
164 # define STL_STDEXCEPT <stdexcept>
165 # define STL_STRING <string>
166 # define STL_STRSTREAM <strstream>
168 # pragma warning(disable: 4786) // identifier was truncated to '255' characters
169 # pragma warning(disable: 4244) // conversion from double to float
170 # pragma warning(disable: 4305) //
173 # error What version of MSVC++ is this?
178 # if defined(HAVE_SGI_STL_PORT)
180 // Use quotes around long file names to get around Borland's include hackery
182 # define STL_ALGORITHM "algorithm"
183 # define STL_FUNCTIONAL "functional"
185 # define FG_MATH_EXCEPTION_CLASH
189 # define STL_ALGORITHM <algorithm>
190 # define STL_FUNCTIONAL <functional>
191 # define STL_IOMANIP <iomanip>
192 # define STL_STDEXCEPT <stdexcept>
193 # define STL_STRSTREAM <strstream>
195 # define FG_INCOMPLETE_FUNCTIONAL
197 # endif // HAVE_SGI_STL_PORT
199 # define STL_IOSTREAM <iostream>
200 # define STL_FSTREAM <fstream>
201 # define STL_STRING <string>
202 # define FG_NO_DEFAULT_TEMPLATE_ARGS
203 # define FG_NAMESPACES
204 // # define FG_HAVE_STD
206 #endif // __BORLANDC__
209 // Native SGI compilers
212 #if defined ( sgi ) && !defined( __GNUC__ )
213 # define FG_HAVE_NATIVE_SGI_COMPILERS
215 # define FG_EXPLICIT_FUNCTION_TMPL_ARGS
216 # define FG_NEED_AUTO_PTR
217 # define FG_MEMBER_TEMPLATES
218 # define FG_NAMESPACES
220 # define FG_CLASS_PARTIAL_SPECIALIZATION
222 # define STL_ALGORITHM <algorithm>
223 # define STL_FUNCTIONAL <functional>
224 # define STL_IOMANIP <iomanip.h>
225 # define STL_IOSTREAM <iostream.h>
226 # define STL_FSTREAM <fstream.h>
227 # define STL_STDEXCEPT <stdexcept>
228 # define STL_STRING <string>
229 # define STL_STRSTREAM <strstream>
231 #endif // Native SGI compilers
235 # include <strings.h>
237 # if defined ( __cplusplus )
238 // typedef unsigned int size_t;
240 extern void *memmove(void *, const void *, size_t);
243 extern void *memmove(void *, const void *, size_t);
244 # endif // __cplusplus
248 // No user modifiable definitions beyond here.
251 #ifdef FG_NEED_EXPLICIT
255 #ifdef FG_NEED_TYPENAME
259 #ifdef FG_NEED_MUTABLE
269 #ifdef FG_EXPLICIT_FUNCTION_TMPL_ARGS
270 # define FG_NULL_TMPL_ARGS <>
272 # define FG_NULL_TMPL_ARGS
275 #ifdef FG_CLASS_PARTIAL_SPECIALIZATION
276 # define FG_TEMPLATE_NULL template<>
278 # define FG_TEMPLATE_NULL
281 // FG_NO_NAMESPACES is a hook so that users can disable namespaces
282 // without having to edit library headers.
283 #if defined(FG_NAMESPACES) && !defined(FG_NO_NAMESPACES)
284 # define FG_NAMESPACE(X) namespace X {
285 # define FG_NAMESPACE_END }
286 # define FG_USING_NAMESPACE(X) using namespace X
288 # define FG_NAMESPACE(X)
289 # define FG_NAMESPACE_END
290 # define FG_USING_NAMESPACE(X)
294 # define FG_USING_STD(X) using std::X
297 # define FG_USING_STD(X)
301 // Additional <functional> implementation from SGI STL 3.11
302 // Adapter function objects: pointers to member functions
303 #ifdef FG_INCOMPLETE_FUNCTIONAL
305 template <class _Ret, class _Tp>
306 class const_mem_fun_ref_t
308 : public unary_function<_Tp,_Ret>
309 #endif // __BORLANDC__
312 explicit const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const) : _M_f(__pf) {}
313 _Ret operator()(const _Tp& __r) const { return (__r.*_M_f)(); }
315 _Ret (_Tp::*_M_f)() const;
318 template <class _Ret, class _Tp>
319 inline const_mem_fun_ref_t<_Ret,_Tp> mem_fun_ref(_Ret (_Tp::*__f)() const)
320 { return const_mem_fun_ref_t<_Ret,_Tp>(__f); }
322 #endif // FG_INCOMPLETE_FUNCTIONAL
324 #endif // _COMPILER_H