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 # if _MSC_VER == 1200 // msvc++ 6.0
131 # define FG_NAMESPACES
133 # define FG_HAVE_STD_INCLUDES
134 # define FG_HAVE_STREAMBUF
136 # define STL_ALGORITHM <algorithm>
137 # define STL_FUNCTIONAL <functional>
138 # define STL_IOMANIP <iomanip>
139 # define STL_IOSTREAM <iostream>
140 # define STL_FSTREAM <fstream>
141 # define STL_STDEXCEPT <stdexcept>
142 # define STL_STRING <string>
143 # define STL_STRSTREAM <strstream>
145 # pragma warning(disable: 4786) // identifier was truncated to '255' characters
146 # pragma warning(disable: 4244) // conversion from double to float
147 # pragma warning(disable: 4305) //
149 # elif _MSC_VER == 1100 // msvc++ 5.0
150 # error MSVC++ 5.0 still to be supported...
152 # error What version of MSVC++ is this?
157 # if defined(HAVE_SGI_STL_PORT)
159 // Use quotes around long file names to get around Borland's include hackery
161 # define STL_ALGORITHM "algorithm"
162 # define STL_FUNCTIONAL "functional"
164 # define FG_MATH_EXCEPTION_CLASH
168 # define STL_ALGORITHM <algorithm>
169 # define STL_FUNCTIONAL <functional>
170 # define STL_IOMANIP <iomanip>
171 # define STL_STDEXCEPT <stdexcept>
172 # define STL_STRSTREAM <strstream>
174 # define FG_INCOMPLETE_FUNCTIONAL
176 # endif // HAVE_SGI_STL_PORT
178 # define STL_IOSTREAM <iostream>
179 # define STL_FSTREAM <fstream>
180 # define STL_STRING <string>
181 # define FG_NO_DEFAULT_TEMPLATE_ARGS
182 # define FG_NAMESPACES
183 // # define FG_HAVE_STD
185 #endif // __BORLANDC__
188 // Native SGI compilers
191 #if defined ( sgi ) && !defined( __GNUC__ )
192 # define FG_HAVE_NATIVE_SGI_COMPILERS
194 # define FG_EXPLICIT_FUNCTION_TMPL_ARGS
195 # define FG_NEED_AUTO_PTR
196 # define FG_MEMBER_TEMPLATES
197 # define FG_NAMESPACES
199 # define FG_CLASS_PARTIAL_SPECIALIZATION
201 # define STL_ALGORITHM <algorithm>
202 # define STL_FUNCTIONAL <functional>
203 # define STL_IOMANIP <iomanip.h>
204 # define STL_IOSTREAM <iostream.h>
205 # define STL_FSTREAM <fstream.h>
206 # define STL_STDEXCEPT <stdexcept>
207 # define STL_STRING <string>
208 # define STL_STRSTREAM <strstream>
210 #endif // Native SGI compilers
214 # include <strings.h>
216 # if defined ( __cplusplus )
217 // typedef unsigned int size_t;
219 extern void *memmove(void *, const void *, size_t);
222 extern void *memmove(void *, const void *, size_t);
223 # endif // __cplusplus
227 // No user modifiable definitions beyond here.
230 #ifdef FG_NEED_EXPLICIT
234 #ifdef FG_NEED_TYPENAME
238 #ifdef FG_NEED_MUTABLE
248 #ifdef FG_EXPLICIT_FUNCTION_TMPL_ARGS
249 # define FG_NULL_TMPL_ARGS <>
251 # define FG_NULL_TMPL_ARGS
254 #ifdef FG_CLASS_PARTIAL_SPECIALIZATION
255 # define FG_TEMPLATE_NULL template<>
257 # define FG_TEMPLATE_NULL
260 // FG_NO_NAMESPACES is a hook so that users can disable namespaces
261 // without having to edit library headers.
262 #if defined(FG_NAMESPACES) && !defined(FG_NO_NAMESPACES)
263 # define FG_NAMESPACE(X) namespace X {
264 # define FG_NAMESPACE_END }
265 # define FG_USING_NAMESPACE(X) using namespace X
267 # define FG_NAMESPACE(X)
268 # define FG_NAMESPACE_END
269 # define FG_USING_NAMESPACE(X)
273 # define FG_USING_STD(X) using std::X
276 # define FG_USING_STD(X)
280 // Additional <functional> implementation from SGI STL 3.11
281 // Adapter function objects: pointers to member functions
282 #ifdef FG_INCOMPLETE_FUNCTIONAL
284 template <class _Ret, class _Tp>
285 class const_mem_fun_ref_t
287 : public unary_function<_Tp,_Ret>
288 #endif // __BORLANDC__
291 explicit const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const) : _M_f(__pf) {}
292 _Ret operator()(const _Tp& __r) const { return (__r.*_M_f)(); }
294 _Ret (_Tp::*_M_f)() const;
297 template <class _Ret, class _Tp>
298 inline const_mem_fun_ref_t<_Ret,_Tp> mem_fun_ref(_Ret (_Tp::*__f)() const)
299 { return const_mem_fun_ref_t<_Ret,_Tp>(__f); }
301 #endif // FG_INCOMPLETE_FUNCTIONAL
303 #endif // _COMPILER_H