From fc2a8872ece13ec6a9eac403a45bbdac0e31a987 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 19 Sep 2010 19:19:23 +0200 Subject: [PATCH] Fixed: Compilation with STLport under Linux --- code/nel/include/nel/misc/common.h | 2 +- code/nel/include/nel/misc/string_common.h | 8 +++ code/nel/include/nel/misc/types_nl.h | 80 +++++++++++------------ 3 files changed, 49 insertions(+), 41 deletions(-) diff --git a/code/nel/include/nel/misc/common.h b/code/nel/include/nel/misc/common.h index 124f6bdab..6363fc25d 100644 --- a/code/nel/include/nel/misc/common.h +++ b/code/nel/include/nel/misc/common.h @@ -206,7 +206,7 @@ inline double isValidDouble (double v) #ifdef NL_OS_WINDOWS return _finite(v) && !_isnan(v); #else - return !std::isnan(v) && !std::isinf(v); + return !isnan(v) && !isinf(v); #endif } diff --git a/code/nel/include/nel/misc/string_common.h b/code/nel/include/nel/misc/string_common.h index 3597ac10e..f9d83910c 100644 --- a/code/nel/include/nel/misc/string_common.h +++ b/code/nel/include/nel/misc/string_common.h @@ -187,6 +187,10 @@ inline std::string toString(const uint32 &val) { return toString("%u", val); } inline std::string toString(const sint32 &val) { return toString("%d", val); } inline std::string toString(const uint64 &val) { return toString("%"NL_I64"u", val); } inline std::string toString(const sint64 &val) { return toString("%"NL_I64"d", val); } + +#ifdef NL_COMP_GCC +# if GCC_VERSION == 40102 + // error fix for size_t? gcc 4.1.2 requested this type instead of size_t ... inline std::string toString(const long unsigned int &val) { @@ -194,6 +198,10 @@ inline std::string toString(const long unsigned int &val) return toString((uint64)val); return toString((uint32)val); } + +# endif +#endif + #if (SIZEOF_SIZE_T) == 8 inline std::string toString(const size_t &val) { return toString("%"NL_I64"u", val); } //#else diff --git a/code/nel/include/nel/misc/types_nl.h b/code/nel/include/nel/misc/types_nl.h index a460f68dc..20118c11c 100644 --- a/code/nel/include/nel/misc/types_nl.h +++ b/code/nel/include/nel/misc/types_nl.h @@ -40,8 +40,10 @@ # define FINAL_VERSION 0 #endif // FINAL_VERSION -// Operating systems definition +// This way we know about _HAS_TR1 and _STLPORT_VERSION +#include +// Operating systems definition #ifdef _WIN32 # define NL_OS_WINDOWS # define NL_LITTLE_ENDIAN @@ -51,7 +53,6 @@ # endif # if _MSC_VER >= 1500 # define NL_COMP_VC9 -# include // This way we know about _HAS_TR1 :O # ifndef _STLPORT_VERSION // STLport doesn't depend on MS STL features # if defined(_HAS_TR1) && (_HAS_TR1 + 0) // VC9 TR1 feature pack # define NL_ISO_STDTR1_AVAILABLE @@ -88,7 +89,7 @@ # ifdef _WIN64 # define NL_OS_WIN64 # ifndef NL_NO_ASM - // Windows 64bits platform SDK compilers doesn't support inline assemblers + // Windows 64bits platform SDK compilers doesn't support inline assembler # define NL_NO_ASM # endif # endif @@ -131,9 +132,12 @@ #endif // gcc 4.1+ provides std::tr1 -#if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 1)) -# define NL_ISO_STDTR1_AVAILABLE -# define NL_ISO_STDTR1_HEADER(header) +#ifdef NL_COMP_GCC +# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +# if GCC_VERSION > 40100 +# define NL_ISO_STDTR1_AVAILABLE +# define NL_ISO_STDTR1_HEADER(header) +# endif #endif // Remove stupid Visual C++ warnings @@ -261,22 +265,6 @@ typedef unsigned int uint; // at least 32bits (depend of processor) #define NL_I64 "I64" -#ifndef NL_ISO_STDTR1_AVAILABLE -# include -# include -# ifdef _STLP_HASH_MAP -# define CHashMap ::std::hash_map -# define CHashSet ::std::hash_set -# define CHashMultiMap ::std::hash_multimap -# elif defined(NL_COMP_VC7) || defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) // VC7 through 9 -# define CHashMap stdext::hash_map -# define CHashSet stdext::hash_set -# define CHashMultiMap stdext::hash_multimap -# else -# pragma error("You need to update your compiler") -# endif -#endif // NL_ISO_STDTR1_AVAILABLE - #elif defined (NL_OS_UNIX) #include @@ -284,20 +272,41 @@ typedef unsigned int uint; // at least 32bits (depend of processor) #include typedef int8_t sint8; -typedef u_int8_t uint8; +typedef uint8_t uint8; typedef int16_t sint16; -typedef u_int16_t uint16; +typedef uint16_t uint16; typedef int32_t sint32; -typedef u_int32_t uint32; -typedef long long int sint64; -typedef unsigned long long int uint64; +typedef uint32_t uint32; +typedef int64_t sint64; +typedef uint64_t uint64; typedef int sint; // at least 32bits (depend of processor) typedef unsigned int uint; // at least 32bits (depend of processor) #define NL_I64 "ll" -#if defined(NL_COMP_GCC) && !defined(NL_ISO_STDTR1_AVAILABLE) // GCC4 +#endif // NL_OS_UNIX + +// CHashMap, CHashSet and CHashMultiMap definitions +#if defined(_STLPORT_VERSION) // STLport detected +# include +# include +# ifdef _STLP_HASH_MAP +# define CHashMap ::std::hash_map +# define CHashSet ::std::hash_set +# define CHashMultiMap ::std::hash_multimap +# endif // _STLP_HASH_MAP +#elif defined(NL_ISO_STDTR1_AVAILABLE) // use std::tr1 for CHash* classes, if available (gcc 4.1+ and VC9 with TR1 feature pack) +# include NL_ISO_STDTR1_HEADER(unordered_map) +# include NL_ISO_STDTR1_HEADER(unordered_set) +# define CHashMap std::tr1::unordered_map +# define CHashSet std::tr1::unordered_set +# define CHashMultiMap std::tr1::unordered_multimap +#elif defined(NL_COMP_VC7) || defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) // VC7 through 9 +# define CHashMap stdext::hash_map +# define CHashSet stdext::hash_set +# define CHashMultiMap stdext::hash_multimap +#elif defined(NL_COMP_GCC) // GCC4 # include # include # define CHashMap ::__gnu_cxx::hash_map @@ -324,18 +333,9 @@ template<> struct hash } // END NAMESPACE __GNU_CXX -#endif // NL_COMP_GCC && !NL_ISO_STDTR1_AVAILABLE - -#endif // NL_OS_UNIX - -// use std::tr1 for CHash* classes, if available (gcc 4.1+ and VC9 with TR1 feature pack) -#ifdef NL_ISO_STDTR1_AVAILABLE -# include NL_ISO_STDTR1_HEADER(unordered_map) -# include NL_ISO_STDTR1_HEADER(unordered_set) -# define CHashMap std::tr1::unordered_map -# define CHashSet std::tr1::unordered_set -# define CHashMultiMap std::tr1::unordered_multimap -#endif +#else +# pragma error("You need to update your compiler") +#endif // _STLPORT_VERSION /** * \typedef ucchar