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_STDEXCEPT <stdexcept>
61 # define STL_STRING <string>
62 # define STL_STRSTREAM <strstream.h>
64 # define FG_NEED_AUTO_PTR
65 # define FG_NO_DEFAULT_TEMPLATE_ARGS
66 # define FG_INCOMPLETE_FUNCTIONAL
67 # define FG_NO_ARROW_OPERATOR
69 # elif __GNUC_MINOR__ >= 8
71 // g++-2.8.x and egcs-1.x
72 # define FG_EXPLICIT_FUNCTION_TMPL_ARGS
73 # define FG_NEED_AUTO_PTR
74 # define FG_MEMBER_TEMPLATES
75 # define FG_NAMESPACES
77 # define FG_HAVE_STREAMBUF
78 # define FG_CLASS_PARTIAL_SPECIALIZATION
80 # define STL_ALGORITHM <algorithm>
81 # define STL_FUNCTIONAL <functional>
82 # define STL_IOMANIP <iomanip>
83 # define STL_IOSTREAM <iostream>
84 # define STL_STDEXCEPT <stdexcept>
85 # define STL_STRING <string>
86 # define STL_STRSTREAM <strstream>
90 # error Time to upgrade. GNU compilers < 2.7 not supported
97 #if defined(__MWERKS__)
99 CodeWarrior compiler from Metrowerks, Inc.
101 # define FG_HAVE_TRAITS
102 # define FG_HAVE_STD_INCLUDES
104 # define FG_NAMESPACES
106 # define STL_ALGORITHM <algorithm>
107 # define STL_FUNCTIONAL <functional>
108 # define STL_IOMANIP <iomanip>
109 # define STL_IOSTREAM <iostream>
110 # define STL_STDEXCEPT <stdexcept>
111 # define STL_STRING <string>
114 # define bcopy(from, to, n) memcpy(to, from, n)
116 // -rp- please use FG_MEM_COPY everywhere !
117 # define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
119 // -dw- currently used glut has no game mode stuff
120 # define GLUT_WRONG_VERSION
124 // Microsoft compilers.
127 # if _MSC_VER == 1200 // msvc++ 6.0
128 # define FG_NAMESPACES
130 # define FG_HAVE_STD_INCLUDES
131 # define FG_HAVE_STREAMBUF
133 # define STL_ALGORITHM <algorithm>
134 # define STL_FUNCTIONAL <functional>
135 # define STL_IOMANIP <iomanip>
136 # define STL_IOSTREAM <iostream>
137 # define STL_STDEXCEPT <stdexcept>
138 # define STL_STRING <string>
139 # define STL_STRSTREAM <strstream>
141 # pragma warning(disable: 4786) // identifier was truncated to '255' characters
142 # pragma warning(disable: 4244) // conversion from double to float
143 # pragma warning(disable: 4305) //
145 # elif _MSC_VER == 1100 // msvc++ 5.0
146 # error MSVC++ 5.0 still to be supported...
148 # error What version of MSVC++ is this?
153 # if defined(HAVE_SGI_STL_PORT)
155 // Use quotes around long file names to get around Borland's include hackery
157 # define STL_ALGORITHM "algorithm"
158 # define STL_FUNCTIONAL "functional"
160 # define FG_MATH_EXCEPTION_CLASH
164 # define STL_ALGORITHM <algorithm>
165 # define STL_FUNCTIONAL <functional>
166 # define STL_IOMANIP <iomanip>
167 # define STL_STDEXCEPT <stdexcept>
168 # define STL_STRSTREAM <strstream>
170 # define FG_INCOMPLETE_FUNCTIONAL
172 # endif // HAVE_SGI_STL_PORT
174 # define STL_IOSTREAM <iostream>
175 # define STL_STRING <string>
176 # define FG_NO_DEFAULT_TEMPLATE_ARGS
177 # define FG_NAMESPACES
178 // # define FG_HAVE_STD
180 #endif // __BORLANDC__
183 // Native SGI compilers
186 #if defined ( sgi ) && !defined( __GNUC__ )
187 # define FG_HAVE_NATIVE_SGI_COMPILERS
189 # define FG_EXPLICIT_FUNCTION_TMPL_ARGS
190 # define FG_NEED_AUTO_PTR
191 # define FG_MEMBER_TEMPLATES
192 # define FG_NAMESPACES
194 # define FG_CLASS_PARTIAL_SPECIALIZATION
196 # define STL_ALGORITHM <algorithm>
197 # define STL_FUNCTIONAL <functional>
198 # define STL_IOMANIP <iomanip>
199 # define STL_IOSTREAM <iostream.h>
200 # define STL_STDEXCEPT <stdexcept>
201 # define STL_STRING <string>
202 # define STL_STRSTREAM <strstream>
204 #endif // Native SGI compilers
209 # if defined ( __cplusplus )
210 // typedef unsigned int size_t;
212 extern void *memmove(void *, const void *, size_t);
215 extern void *memmove(void *, const void *, size_t);
216 # endif // __cplusplus
220 // No user modifiable definitions beyond here.
223 #ifdef FG_NEED_EXPLICIT
227 #ifdef FG_NEED_TYPENAME
231 #ifdef FG_NEED_MUTABLE
241 #ifdef FG_EXPLICIT_FUNCTION_TMPL_ARGS
242 # define FG_NULL_TMPL_ARGS <>
244 # define FG_NULL_TMPL_ARGS
247 #ifdef FG_CLASS_PARTIAL_SPECIALIZATION
248 # define FG_TEMPLATE_NULL template<>
250 # define FG_TEMPLATE_NULL
253 // FG_NO_NAMESPACES is a hook so that users can disable namespaces
254 // without having to edit library headers.
255 #if defined(FG_NAMESPACES) && !defined(FG_NO_NAMESPACES)
256 # define FG_NAMESPACE(X) namespace X {
257 # define FG_NAMESPACE_END }
258 # define FG_USING_NAMESPACE(X) using namespace X
260 # define FG_NAMESPACE(X)
261 # define FG_NAMESPACE_END
262 # define FG_USING_NAMESPACE(X)
266 # define FG_USING_STD(X) using std::X
269 # define FG_USING_STD(X)
273 // Additional <functional> implementation from SGI STL 3.11
274 // Adapter function objects: pointers to member functions
275 #ifdef FG_INCOMPLETE_FUNCTIONAL
277 template <class _Ret, class _Tp>
278 class const_mem_fun_ref_t
280 : public unary_function<_Tp,_Ret>
281 #endif // __BORLANDC__
284 explicit const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const) : _M_f(__pf) {}
285 _Ret operator()(const _Tp& __r) const { return (__r.*_M_f)(); }
287 _Ret (_Tp::*_M_f)() const;
290 template <class _Ret, class _Tp>
291 inline const_mem_fun_ref_t<_Ret,_Tp> mem_fun_ref(_Ret (_Tp::*__f)() const)
292 { return const_mem_fun_ref_t<_Ret,_Tp>(__f); }
294 #endif // FG_INCOMPLETE_FUNCTIONAL
296 #endif // _COMPILER_H