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 #if defined(__MWERKS__)
102 CodeWarrior compiler from Metrowerks, Inc.
104 # define FG_HAVE_TRAITS
105 # define FG_HAVE_STD_INCLUDES
107 # define FG_NAMESPACES
109 # define STL_ALGORITHM <algorithm>
110 # define STL_FUNCTIONAL <functional>
111 # define STL_IOMANIP <iomanip>
112 # define STL_IOSTREAM <iostream>
113 # define STL_FSTREAM <fstream>
114 # define STL_STDEXCEPT <stdexcept>
115 # define STL_STRING <string>
118 # define bcopy(from, to, n) memcpy(to, from, n)
120 // -rp- please use FG_MEM_COPY everywhere !
121 # define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
123 // -dw- currently used glut has no game mode stuff
124 # define GLUT_WRONG_VERSION
128 // Microsoft compilers.
131 # define bcopy(from, to, n) memcpy(to, from, n)
132 # define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
134 # if _MSC_VER == 1200 // msvc++ 6.0
135 # define FG_NAMESPACES
137 # define FG_HAVE_STD_INCLUDES
138 # define FG_HAVE_STREAMBUF
140 # define STL_ALGORITHM <algorithm>
141 # define STL_FUNCTIONAL <functional>
142 # define STL_IOMANIP <iomanip>
143 # define STL_IOSTREAM <iostream>
144 # define STL_FSTREAM <fstream>
145 # define STL_STDEXCEPT <stdexcept>
146 # define STL_STRING <string>
147 # define STL_STRSTREAM <strstream>
149 # pragma warning(disable: 4786) // identifier was truncated to '255' characters
150 # pragma warning(disable: 4244) // conversion from double to float
151 # pragma warning(disable: 4305) //
153 # elif _MSC_VER == 1100 // msvc++ 5.0
154 # define NEEDNAMESPACESTD
155 # define FG_NAMESPACES
157 # define FG_HAVE_STD_INCLUDES
158 # define FG_HAVE_STREAMBUF
160 # define STL_ALGORITHM <algorithm>
161 # define STL_FUNCTIONAL <functional>
162 # define STL_IOMANIP <iomanip>
163 # define STL_IOSTREAM <iostream>
164 # define STL_FSTREAM <fstream>
165 # define STL_STDEXCEPT <stdexcept>
166 # define STL_STRING <string>
167 # define STL_STRSTREAM <strstream>
169 # pragma warning(disable: 4786) // identifier was truncated to '255' characters
170 # pragma warning(disable: 4244) // conversion from double to float
171 # pragma warning(disable: 4305) //
174 # error What version of MSVC++ is this?
179 # if defined(HAVE_SGI_STL_PORT)
181 // Use quotes around long file names to get around Borland's include hackery
183 # define STL_ALGORITHM "algorithm"
184 # define STL_FUNCTIONAL "functional"
186 # define FG_MATH_EXCEPTION_CLASH
190 # define STL_ALGORITHM <algorithm>
191 # define STL_FUNCTIONAL <functional>
192 # define STL_IOMANIP <iomanip>
193 # define STL_STDEXCEPT <stdexcept>
194 # define STL_STRSTREAM <strstream>
196 # define FG_INCOMPLETE_FUNCTIONAL
198 # endif // HAVE_SGI_STL_PORT
200 # define STL_IOSTREAM <iostream>
201 # define STL_FSTREAM <fstream>
202 # define STL_STRING <string>
203 # define FG_NO_DEFAULT_TEMPLATE_ARGS
204 # define FG_NAMESPACES
205 // # define FG_HAVE_STD
207 #endif // __BORLANDC__
210 // Native SGI compilers
213 #if defined ( sgi ) && !defined( __GNUC__ )
214 # define FG_HAVE_NATIVE_SGI_COMPILERS
216 # define FG_EXPLICIT_FUNCTION_TMPL_ARGS
217 # define FG_NEED_AUTO_PTR
218 # define FG_MEMBER_TEMPLATES
219 # define FG_NAMESPACES
221 # define FG_CLASS_PARTIAL_SPECIALIZATION
223 # define STL_ALGORITHM <algorithm>
224 # define STL_FUNCTIONAL <functional>
225 # define STL_IOMANIP <iomanip.h>
226 # define STL_IOSTREAM <iostream.h>
227 # define STL_FSTREAM <fstream.h>
228 # define STL_STDEXCEPT <stdexcept>
229 # define STL_STRING <string>
230 # define STL_STRSTREAM <strstream>
232 #endif // Native SGI compilers
236 # include <strings.h>
238 # if defined ( __cplusplus )
239 // typedef unsigned int size_t;
241 extern void *memmove(void *, const void *, size_t);
244 extern void *memmove(void *, const void *, size_t);
245 # endif // __cplusplus
249 // No user modifiable definitions beyond here.
252 #ifdef FG_NEED_EXPLICIT
256 #ifdef FG_NEED_TYPENAME
260 #ifdef FG_NEED_MUTABLE
270 #ifdef FG_EXPLICIT_FUNCTION_TMPL_ARGS
271 # define FG_NULL_TMPL_ARGS <>
273 # define FG_NULL_TMPL_ARGS
276 #ifdef FG_CLASS_PARTIAL_SPECIALIZATION
277 # define FG_TEMPLATE_NULL template<>
279 # define FG_TEMPLATE_NULL
282 // FG_NO_NAMESPACES is a hook so that users can disable namespaces
283 // without having to edit library headers.
284 #if defined(FG_NAMESPACES) && !defined(FG_NO_NAMESPACES)
285 # define FG_NAMESPACE(X) namespace X {
286 # define FG_NAMESPACE_END }
287 # define FG_USING_NAMESPACE(X) using namespace X
289 # define FG_NAMESPACE(X)
290 # define FG_NAMESPACE_END
291 # define FG_USING_NAMESPACE(X)
295 # define FG_USING_STD(X) using std::X
298 # define FG_USING_STD(X)
302 // Additional <functional> implementation from SGI STL 3.11
303 // Adapter function objects: pointers to member functions
304 #ifdef FG_INCOMPLETE_FUNCTIONAL
306 template <class _Ret, class _Tp>
307 class const_mem_fun_ref_t
309 : public unary_function<_Tp,_Ret>
310 #endif // __BORLANDC__
313 explicit const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const) : _M_f(__pf) {}
314 _Ret operator()(const _Tp& __r) const { return (__r.*_M_f)(); }
316 _Ret (_Tp::*_M_f)() const;
319 template <class _Ret, class _Tp>
320 inline const_mem_fun_ref_t<_Ret,_Tp> mem_fun_ref(_Ret (_Tp::*__f)() const)
321 { return const_mem_fun_ref_t<_Ret,_Tp>(__f); }
323 #endif // FG_INCOMPLETE_FUNCTIONAL
325 #endif // _COMPILER_H