compiler.h

Go to the documentation of this file.
00001 /**************************************************************************
00002  * compiler.h -- C++ Compiler Portability Macros
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00017  *
00018  * $Id: compiler_8h-source.html,v 1.15 2007-12-17 15:37:00 curt Exp $
00019  *
00020  **************************************************************************/
00021 
00070 #ifndef _SG_COMPILER_H
00071 #define _SG_COMPILER_H
00072 
00073 /*
00074  * Helper macro SG_STRINGIZE:
00075  * Converts the parameter X to a string after macro replacement
00076  * on X has been performed.
00077  */
00078 #define SG_STRINGIZE(X) SG_DO_STRINGIZE(X)
00079 #define SG_DO_STRINGIZE(X) #X
00080 
00081 #ifdef __GNUC__
00082 #  if __GNUC__ == 2 
00083 #    if __GNUC_MINOR__ < 8
00084 
00085        // g++-2.7.x
00086 #      define STL_ALGORITHM  <algorithm>
00087 #      define STL_FUNCTIONAL <functional>
00088 #      define STL_IOMANIP    <iomanip.h>
00089 #      define STL_IOSTREAM   <iostream.h>
00090 #      define STL_ITERATOR   <iterator.h>
00091 #      define STL_FSTREAM    <fstream.h>
00092 #      define STL_STDEXCEPT  <stdexcept>
00093 #      define STL_STRING     <string>
00094 #      define STL_STRSTREAM  <strstream.h>
00095 
00096 #      define SG_NEED_AUTO_PTR
00097 #      define SG_NO_DEFAULT_TEMPLATE_ARGS
00098 #      define SG_INCOMPLETE_FUNCTIONAL
00099 #      define SG_NO_ARROW_OPERATOR
00100 
00101 #    elif __GNUC_MINOR__ >= 8
00102 
00103        // g++-2.8.x and egcs-1.x
00104 #      define SG_EXPLICIT_FUNCTION_TMPL_ARGS
00105 #      define SG_NEED_AUTO_PTR
00106 #      define SG_MEMBER_TEMPLATES
00107 #      define SG_NAMESPACES
00108 #      define SG_HAVE_STD
00109 #      define SG_HAVE_STREAMBUF
00110 #      define SG_CLASS_PARTIAL_SPECIALIZATION
00111 
00112 #      define STL_ALGORITHM  <algorithm>
00113 #      define STL_FUNCTIONAL <functional>
00114 #      define STL_IOMANIP    <iomanip>
00115 #      define STL_IOSTREAM   <iostream>
00116 #      define STL_ITERATOR   <iterator>
00117 #      define STL_FSTREAM    <fstream>
00118 #      define STL_STDEXCEPT  <stdexcept>
00119 #      define STL_STRING     <string>
00120 #      define STL_STRSTREAM  <strstream>
00121 
00122 #    endif
00123 #  elif __GNUC__ >= 3
00124        // g++-3.0.x
00125 #      define SG_EXPLICIT_FUNCTION_TMPL_ARGS
00126 #      define SG_NEED_AUTO_PTR
00127 #      define SG_MEMBER_TEMPLATES
00128 #      define SG_NAMESPACES
00129 #      define SG_HAVE_STD
00130 #      define SG_HAVE_STREAMBUF
00131 #      define SG_CLASS_PARTIAL_SPECIALIZATION
00132 #      define SG_HAVE_STD_INCLUDES
00133 
00134 #      define STL_ALGORITHM  <algorithm>
00135 #      define STL_FUNCTIONAL <functional>
00136 #      define STL_IOMANIP    <iomanip>
00137 #      define STL_IOSTREAM   <iostream>
00138 #      define STL_ITERATOR   <iterator>
00139 #      define STL_FSTREAM    <fstream>
00140 #      define STL_STDEXCEPT  <stdexcept>
00141 #      define STL_STRING     <string>
00142 #      define STL_STRSTREAM  <strstream>
00143 #  else
00144 #    error Time to upgrade. GNU compilers < 2.7 not supported
00145 #  endif
00146 
00147 #  define SG_COMPILER_STR "GNU C++ version " SG_STRINGIZE(__GNUC__) "." SG_STRINGIZE(__GNUC_MINOR__)
00148 
00149 #endif // __GNUC__
00150 
00151 /* KAI C++ */
00152 #if defined(__KCC)
00153 
00154 #  define SG_NAMESPACES
00155 #  define SG_HAVE_STD
00156 #  define SG_HAVE_STREAMBUF
00157 #  define SG_HAVE_TRAITS
00158 #  define SG_HAVE_STD_INCLUDES
00159 
00160 #  define STL_ALGORITHM  <algorithm>
00161 #  define STL_FUNCTIONAL <functional>
00162 #  define STL_IOMANIP    <iomanip>
00163 #  define STL_IOSTREAM   <iostream>
00164 #  define STL_ITERATOR   <iterator>
00165 #  define STL_FSTREAM    <fstream>
00166 #  define STL_STDEXCEPT  <stdexcept>
00167 #  define STL_STRING     <string>
00168 #  define STL_STRSTREAM  <strstream>
00169 
00170 #  define SG_COMPILER_STR "Kai C++ version " SG_STRINGIZE(__KCC_VERSION)
00171 
00172 #endif // __KCC
00173 
00174 //
00175 // Metrowerks 
00176 //
00177 #if defined(__MWERKS__)
00178 /*
00179   CodeWarrior compiler from Metrowerks, Inc.
00180 */
00181 #  define SG_HAVE_TRAITS
00182 #  define SG_HAVE_STD_INCLUDES
00183 #  define SG_HAVE_STD
00184 #  define SG_NAMESPACES
00185 
00186 #  define STL_ALGORITHM  <algorithm>
00187 #  define STL_FUNCTIONAL <functional>
00188 #  define STL_IOMANIP    <iomanip>
00189 #  define STL_IOSTREAM   <iostream>
00190 #  define STL_ITERATOR   <iterator>
00191 #  define STL_FSTREAM    <fstream>
00192 #  define STL_STDEXCEPT  <stdexcept>
00193 #  define STL_STRING     <string>
00194 
00195 // Temp:
00196 #  define bcopy(from, to, n) memcpy(to, from, n)
00197 
00198 // -rp- please use FG_MEM_COPY everywhere !
00199 // #define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
00200 
00201 // -dw- currently used glut has no game mode stuff
00202 #  define GLUT_WRONG_VERSION
00203 
00204 #  define SG_COMPILER_STR "Metrowerks CodeWarrior C++ version " SG_STRINGIZE(__MWERKS__)
00205 
00206 #endif // __MWERKS__
00207 
00208 //
00209 // Microsoft compilers.
00210 //
00211 #ifdef _MSC_VER
00212 #  define bcopy(from, to, n) memcpy(to, from, n)
00213 #  define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
00214 
00215 #  if _MSC_VER >= 1200  // msvc++ 6.0 or greater
00216 #    define SG_NAMESPACES
00217 #    define SG_HAVE_STD
00218 #    define SG_HAVE_STD_INCLUDES
00219 #    define SG_HAVE_STREAMBUF
00220 
00221 #    define STL_ALGORITHM  <algorithm>
00222 #    define STL_FUNCTIONAL <functional>
00223 #    define STL_IOMANIP    <iomanip>
00224 #    define STL_IOSTREAM   <iostream>
00225 #    define STL_ITERATOR   <iterator>
00226 #    define STL_FSTREAM    <fstream>
00227 #    define STL_STDEXCEPT  <stdexcept>
00228 #    define STL_STRING     <string>
00229 #    define STL_STRSTREAM  <strstream>
00230 
00231 #    define isnan _isnan
00232 #    define snprintf _snprintf
00233 
00234 #    pragma warning(disable: 4786) // identifier was truncated to '255' characters
00235 #    pragma warning(disable: 4244) // conversion from double to float
00236 #    pragma warning(disable: 4305) //
00237 
00238 #  else
00239 #    error What version of MSVC++ is this?
00240 #  endif
00241 
00242 #    define SG_COMPILER_STR "Microsoft Visual C++ version " SG_STRINGIZE(_MSC_VER)
00243 
00244 #endif // _MSC_VER
00245 
00246 #ifdef __BORLANDC__
00247 # if defined(HAVE_SGI_STL_PORT)
00248 
00249 // Use quotes around long file names to get around Borland's include hackery
00250 
00251 #  define STL_ALGORITHM  "algorithm"
00252 #  define STL_FUNCTIONAL "functional"
00253 
00254 #  define SG_MATH_EXCEPTION_CLASH
00255 
00256 # else
00257 
00258 #  define STL_ALGORITHM  <algorithm>
00259 #  define STL_FUNCTIONAL <functional>
00260 #  define STL_IOMANIP    <iomanip>
00261 #  define STL_STDEXCEPT  <stdexcept>
00262 #  define STL_STRSTREAM  <strstream>
00263 
00264 #  define SG_INCOMPLETE_FUNCTIONAL
00265 
00266 # endif // HAVE_SGI_STL_PORT
00267 
00268 #  define STL_IOSTREAM   <iostream>
00269 #  define STL_ITERATOR   <iterator>
00270 #  define STL_FSTREAM    <fstream>
00271 #  define STL_STRING     <string>
00272 #  define SG_NO_DEFAULT_TEMPLATE_ARGS
00273 #  define SG_NAMESPACES
00274 // #  define SG_HAVE_STD
00275 
00276 #  define SG_COMPILER_STR "Borland C++ version " SG_STRINGIZE(__BORLANDC__)
00277 
00278 #endif // __BORLANDC__
00279 
00280 //
00281 // Native SGI compilers
00282 //
00283 
00284 #if defined ( sgi ) && !defined( __GNUC__ )
00285 #  define SG_HAVE_NATIVE_SGI_COMPILERS
00286 
00287 #  define SG_EXPLICIT_FUNCTION_TMPL_ARGS
00288 #  define SG_CLASS_PARTIAL_SPECIALIZATION
00289 #  define SG_NEED_AUTO_PTR
00290 #  define SG_MEMBER_TEMPLATES
00291 #  define SG_NAMESPACES
00292 #  define SG_HAVE_STD
00293 #  define SG_HAVE_STREAMBUF
00294 #  define SG_HAVE_TRAITS
00295 #  define SG_HAVE_STD_INCLUDES
00296 
00297 #  define STL_ALGORITHM  <algorithm>
00298 #  define STL_FUNCTIONAL <functional>
00299 #  define STL_IOMANIP    <iomanip>
00300 #  define STL_IOSTREAM   <iostream>
00301 #  define STL_ITERATOR   <iterator>
00302 #  define STL_FSTREAM    <fstream>
00303 #  define STL_STDEXCEPT  <stdexcept>
00304 #if (_COMPILER_VERSION < 740)
00305 #  define STL_STRING     <irix_string>
00306 #else
00307 #  define STL_STRING     <string>
00308 #endif
00309 #  define STL_STRSTREAM  <strstream>
00310 
00311 #pragma set woff 1001,1012,1014,1116,1155,1172,1174
00312 #pragma set woff 1401,1460,1551,1552,1681
00313 
00314 #ifdef __cplusplus
00315 #pragma set woff 1682,3303
00316 #if (_COMPILER_VERSION >= 740)
00317 #  pragma set woff 3624
00318 #endif
00319 #endif
00320 
00321 #  define SG_COMPILER_STR "SGI MipsPro compiler version " SG_STRINGIZE(_COMPILER_VERSION)
00322 
00323 #endif // Native SGI compilers
00324 
00325 
00326 #if defined (__sun)
00327 #  include <strings.h>
00328 #  include <memory.h>
00329 #  if defined ( __cplusplus )
00330      // typedef unsigned int size_t;
00331      extern "C" {
00332        extern void *memmove(void *, const void *, size_t);
00333      }
00334 #  else
00335      extern void *memmove(void *, const void *, size_t);
00336 #  endif // __cplusplus
00337 
00338 #  if  !defined( __GNUC__ )
00339 #   define SG_COMPILER_STR "Sun compiler version " SG_STRINGIZE(__SUNPRO_CC)
00340 #  endif
00341 
00342 #endif // sun
00343 
00344 //
00345 // Intel C++ Compiler
00346 //
00347 #if defined(__ICC) || defined (__ECC)
00348 #  define SG_NAMESPACES
00349 #  define SG_HAVE_STD
00350 #  define SG_HAVE_STREAMBUF
00351 #  define SG_HAVE_TRAITS
00352 #  define SG_HAVE_STD_INCLUDES
00353 
00354 #  define STL_ALGORITHM  <algorithm>
00355 #  define STL_FUNCTIONAL <functional>
00356 #  define STL_IOMANIP    <iomanip>
00357 #  define STL_IOSTREAM   <iostream>
00358 #  define STL_ITERATOR   <iterator>
00359 #  define STL_FSTREAM    <fstream>
00360 #  define STL_STDEXCEPT  <stdexcept>
00361 #  define STL_STRING     <string>
00362 #  define STL_STRSTREAM  <strstream>
00363 
00364 #  define SG_COMPILER_STR "Intel C++ version " SG_STRINGIZE(__ICC)
00365 
00366 #endif // __ICC
00367 
00368 //
00369 // Platform dependent gl.h and glut.h definitions
00370 //
00371 
00372 #ifdef __APPLE__
00373 #  define SG_GL_H <OpenGL/gl.h>
00374 #  define SG_GLX_H <AGL/agl.h>
00375 #  define SG_GLU_H <OpenGL/glu.h>
00376 #  define SG_GLEXT_H <OpenGL/glext.h>
00377 #  define SG_GLUT_H <GLUT/glut.h>
00378 
00379 inline int (isnan)(double r) { return !(r <= 0 || r >= 0); }
00380 #else
00381 #  define SG_GL_H <GL/gl.h>
00382 #  define SG_GLX_H <GL/glx.h>
00383 #  define SG_GLU_H <GL/glu.h>
00384 #  define SG_GLEXT_H <GL/glext.h>
00385 #  define SG_GLUT_H <GL/glut.h>
00386 #endif
00387 
00388 
00389 //
00390 // No user modifiable definitions beyond here.
00391 //
00392 
00393 #ifdef SG_NEED_EXPLICIT
00394 #  define explicit
00395 #endif
00396 
00397 #ifdef SG_NEED_TYPENAME
00398 #  define typename
00399 #endif
00400 
00401 #ifdef SG_NEED_MUTABLE
00402 #  define mutable
00403 #endif
00404 
00405 #ifdef SG_NEED_BOOL
00406    typedef int bool;
00407 #  define true 1
00408 #  define false 0
00409 #endif
00410 
00411 #ifdef SG_EXPLICIT_FUNCTION_TMPL_ARGS
00412 #  define SG_NULL_TMPL_ARGS <>
00413 #else
00414 #  define SG_NULL_TMPL_ARGS
00415 #endif
00416 
00417 #ifdef SG_CLASS_PARTIAL_SPECIALIZATION
00418 # define SG_TEMPLATE_NULL template<>
00419 #else
00420 # define SG_TEMPLATE_NULL
00421 #endif
00422 
00423 // SG_NO_NAMESPACES is a hook so that users can disable namespaces
00424 // without having to edit library headers.
00425 #if defined(SG_NAMESPACES) && !defined(SG_NO_NAMESPACES)
00426 #   define SG_NAMESPACE(X) namespace X {
00427 #   define SG_NAMESPACE_END }
00428 #   define SG_USING_NAMESPACE(X) using namespace X
00429 # else
00430 #   define SG_NAMESPACE(X)
00431 #   define SG_NAMESPACE_END
00432 #   define SG_USING_NAMESPACE(X)
00433 #endif
00434 
00438 # ifdef SG_HAVE_STD
00439 #  define SG_USING_STD(X) using std::X
00440 #  define STD std
00441 # else
00442 #  define SG_USING_STD(X) 
00443 #  define STD
00444 # endif
00445 
00446 // Additional <functional> implementation from SGI STL 3.11
00447 // Adapter function objects: pointers to member functions
00448 #ifdef SG_INCOMPLETE_FUNCTIONAL
00449 
00450 template <class _Ret, class _Tp>
00451 class const_mem_fun_ref_t
00452 #ifndef __BORLANDC__
00453     : public unary_function<_Tp,_Ret>
00454 #endif // __BORLANDC__
00455 {
00456 public:
00457   explicit const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const) : _M_f(__pf) {}
00458   _Ret operator()(const _Tp& __r) const { return (__r.*_M_f)(); }
00459 private:
00460   _Ret (_Tp::*_M_f)() const;
00461 };
00462 
00463 template <class _Ret, class _Tp>
00464 inline const_mem_fun_ref_t<_Ret,_Tp> mem_fun_ref(_Ret (_Tp::*__f)() const)
00465   { return const_mem_fun_ref_t<_Ret,_Tp>(__f); }
00466 
00467 #endif // SG_INCOMPLETE_FUNCTIONAL
00468 
00469 #endif // _SG_COMPILER_H
00470 

Generated on Mon Dec 17 09:30:54 2007 for SimGear by  doxygen 1.5.1