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 Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 **************************************************************************/
25 // What this file does.
26 // (1) Defines macros for some STL includes which may be affected
27 // by file name length limitations.
28 // (2) Defines macros for some features not supported by all C++ compilers.
29 // (3) Defines 'explicit' as a null macro if the compiler doesn't support
30 // the explicit keyword.
31 // (4) Defines 'typename' as a null macro if the compiler doesn't support
32 // the typename keyword.
33 // (5) Defines bool, true and false if the compiler doesn't do so.
34 // (6) Defines FG_EXPLICIT_FUNCTION_TMPL_ARGS if the compiler
35 // supports calling a function template by providing its template
36 // arguments explicitly.
37 // (7) Defines FG_NEED_AUTO_PTR if STL doesn't provide auto_ptr<>.
38 // (8) Defines FG_NO_ARROW_OPERATOR if the compiler is unable
39 // to support operator->() for iterators.
40 // (9) Defines FG_USE_EXCEPTIONS if the compiler supports exceptions.
41 // Note: no FlightGear code uses exceptions.
42 // (10) Define FG_NAMESPACES if the compiler supports namespaces.
43 // (11) FG_MATH_FN_IN_NAMESPACE_STD -- not used??
44 // (12) Define FG_HAVE_STD if std namespace is supported.
45 // (13) Defines FG_CLASS_PARTIAL_SPECIALIZATION if the compiler
46 // supports partial specialization of class templates.
47 // (14) Defines FG_HAVE_STD_INCLUDES to use ISO C++ Standard headers.
48 // (15) Defines FG_HAVE_STREAMBUF if <streambuf> of <streambuf.h> are present.
49 // (16) Define FG_MATH_EXCEPTION_CLASH if math.h defines an exception class
50 // that clashes with the one defined in <stdexcept>.
54 # if __GNUC_MINOR__ < 8
57 # define STL_ALGORITHM <algorithm>
58 # define STL_FUNCTIONAL <functional>
59 # define STL_IOMANIP <iomanip.h>
60 # define STL_IOSTREAM <iostream.h>
61 # define STL_FSTREAM <fstream.h>
62 # define STL_STDEXCEPT <stdexcept>
63 # define STL_STRING <string>
64 # define STL_STRSTREAM <strstream.h>
66 # define FG_NEED_AUTO_PTR
67 # define FG_NO_DEFAULT_TEMPLATE_ARGS
68 # define FG_INCOMPLETE_FUNCTIONAL
69 # define FG_NO_ARROW_OPERATOR
71 # elif __GNUC_MINOR__ >= 8
73 // g++-2.8.x and egcs-1.x
74 # define FG_EXPLICIT_FUNCTION_TMPL_ARGS
75 # define FG_NEED_AUTO_PTR
76 # define FG_MEMBER_TEMPLATES
77 # define FG_NAMESPACES
79 # define FG_HAVE_STREAMBUF
80 # define FG_CLASS_PARTIAL_SPECIALIZATION
82 # define STL_ALGORITHM <algorithm>
83 # define STL_FUNCTIONAL <functional>
84 # define STL_IOMANIP <iomanip>
85 # define STL_IOSTREAM <iostream>
86 # define STL_FSTREAM <fstream>
87 # define STL_STDEXCEPT <stdexcept>
88 # define STL_STRING <string>
89 # define STL_STRSTREAM <strstream>
93 # error Time to upgrade. GNU compilers < 2.7 not supported
100 # define FG_NAMESPACES
102 # define FG_HAVE_STREAMBUF
103 # define FG_HAVE_TRAITS
104 # define FG_HAVE_STD_INCLUDES
106 # define STL_ALGORITHM <algorithm>
107 # define STL_FUNCTIONAL <functional>
108 # define STL_IOMANIP <iomanip>
109 # define STL_IOSTREAM <iostream>
110 # define STL_FSTREAM <fstream>
111 # define STL_STDEXCEPT <stdexcept>
112 # define STL_STRING <string>
113 # define STL_STRSTREAM <strstream>
119 #if defined(__MWERKS__)
121 CodeWarrior compiler from Metrowerks, Inc.
123 # define FG_HAVE_TRAITS
124 # define FG_HAVE_STD_INCLUDES
126 # define FG_NAMESPACES
128 # define STL_ALGORITHM <algorithm>
129 # define STL_FUNCTIONAL <functional>
130 # define STL_IOMANIP <iomanip>
131 # define STL_IOSTREAM <iostream>
132 # define STL_FSTREAM <fstream>
133 # define STL_STDEXCEPT <stdexcept>
134 # define STL_STRING <string>
137 # define bcopy(from, to, n) memcpy(to, from, n)
139 // -rp- please use FG_MEM_COPY everywhere !
140 // #define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
142 // -dw- currently used glut has no game mode stuff
143 # define GLUT_WRONG_VERSION
147 // Microsoft compilers.
150 # define bcopy(from, to, n) memcpy(to, from, n)
151 # define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
153 # if _MSC_VER == 1200 // msvc++ 6.0
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) //
172 # elif _MSC_VER == 1100 // msvc++ 5.0
173 # define NEEDNAMESPACESTD
174 # define FG_NAMESPACES
176 # define FG_HAVE_STD_INCLUDES
177 # define FG_HAVE_STREAMBUF
179 # define STL_ALGORITHM <algorithm>
180 # define STL_FUNCTIONAL <functional>
181 # define STL_IOMANIP <iomanip>
182 # define STL_IOSTREAM <iostream>
183 # define STL_FSTREAM <fstream>
184 # define STL_STDEXCEPT <stdexcept>
185 # define STL_STRING <string>
186 # define STL_STRSTREAM <strstream>
188 # pragma warning(disable: 4786) // identifier was truncated to '255' characters
189 # pragma warning(disable: 4244) // conversion from double to float
190 # pragma warning(disable: 4305) //
193 # error What version of MSVC++ is this?
198 # if defined(HAVE_SGI_STL_PORT)
200 // Use quotes around long file names to get around Borland's include hackery
202 # define STL_ALGORITHM "algorithm"
203 # define STL_FUNCTIONAL "functional"
205 # define FG_MATH_EXCEPTION_CLASH
209 # define STL_ALGORITHM <algorithm>
210 # define STL_FUNCTIONAL <functional>
211 # define STL_IOMANIP <iomanip>
212 # define STL_STDEXCEPT <stdexcept>
213 # define STL_STRSTREAM <strstream>
215 # define FG_INCOMPLETE_FUNCTIONAL
217 # endif // HAVE_SGI_STL_PORT
219 # define STL_IOSTREAM <iostream>
220 # define STL_FSTREAM <fstream>
221 # define STL_STRING <string>
222 # define FG_NO_DEFAULT_TEMPLATE_ARGS
223 # define FG_NAMESPACES
224 // # define FG_HAVE_STD
226 #endif // __BORLANDC__
229 // Native SGI compilers
232 #if defined ( sgi ) && !defined( __GNUC__ )
233 # define FG_HAVE_NATIVE_SGI_COMPILERS
235 # define FG_EXPLICIT_FUNCTION_TMPL_ARGS
236 # define FG_NEED_AUTO_PTR
237 # define FG_MEMBER_TEMPLATES
238 # define FG_NAMESPACES
240 # define FG_CLASS_PARTIAL_SPECIALIZATION
242 # define STL_ALGORITHM <algorithm>
243 # define STL_FUNCTIONAL <functional>
244 # define STL_IOMANIP <iomanip.h>
245 # define STL_IOSTREAM <iostream.h>
246 # define STL_FSTREAM <fstream.h>
247 # define STL_STDEXCEPT <stdexcept>
248 # define STL_STRING <string>
249 # define STL_STRSTREAM <strstream>
251 #endif // Native SGI compilers
255 # include <strings.h>
257 # if defined ( __cplusplus )
258 // typedef unsigned int size_t;
260 extern void *memmove(void *, const void *, size_t);
263 extern void *memmove(void *, const void *, size_t);
264 # endif // __cplusplus
268 // No user modifiable definitions beyond here.
271 #ifdef FG_NEED_EXPLICIT
275 #ifdef FG_NEED_TYPENAME
279 #ifdef FG_NEED_MUTABLE
289 #ifdef FG_EXPLICIT_FUNCTION_TMPL_ARGS
290 # define FG_NULL_TMPL_ARGS <>
292 # define FG_NULL_TMPL_ARGS
295 #ifdef FG_CLASS_PARTIAL_SPECIALIZATION
296 # define FG_TEMPLATE_NULL template<>
298 # define FG_TEMPLATE_NULL
301 // FG_NO_NAMESPACES is a hook so that users can disable namespaces
302 // without having to edit library headers.
303 #if defined(FG_NAMESPACES) && !defined(FG_NO_NAMESPACES)
304 # define FG_NAMESPACE(X) namespace X {
305 # define FG_NAMESPACE_END }
306 # define FG_USING_NAMESPACE(X) using namespace X
308 # define FG_NAMESPACE(X)
309 # define FG_NAMESPACE_END
310 # define FG_USING_NAMESPACE(X)
314 # define FG_USING_STD(X) using std::X
317 # define FG_USING_STD(X)
321 // Additional <functional> implementation from SGI STL 3.11
322 // Adapter function objects: pointers to member functions
323 #ifdef FG_INCOMPLETE_FUNCTIONAL
325 template <class _Ret, class _Tp>
326 class const_mem_fun_ref_t
328 : public unary_function<_Tp,_Ret>
329 #endif // __BORLANDC__
332 explicit const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const) : _M_f(__pf) {}
333 _Ret operator()(const _Tp& __r) const { return (__r.*_M_f)(); }
335 _Ret (_Tp::*_M_f)() const;
338 template <class _Ret, class _Tp>
339 inline const_mem_fun_ref_t<_Ret,_Tp> mem_fun_ref(_Ret (_Tp::*__f)() const)
340 { return const_mem_fun_ref_t<_Ret,_Tp>(__f); }
342 #endif // FG_INCOMPLETE_FUNCTIONAL
344 #endif // _COMPILER_H