head 1.4; access; symbols; locks; strict; comment @# @; 1.4 date 2002.09.07.01.50.37; author curt; state Exp; branches; next 1.3; 1.3 date 2002.08.31.19.01.53; author curt; state Exp; branches; next 1.2; 1.2 date 2002.08.31.18.54.00; author curt; state Exp; branches; next 1.1; 1.1 date 2002.02.15.17.21.55; author curt; state Exp; branches; next ; desc @@ 1.4 log @Updated doxygen docs. @ text @
Main Page Class Hierarchy Compound List File List Compound Members File Members

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

@ 1.3 log @Oops, try again. @ text @d408 1 a408 1