From 9eae52a7cdfb6c0d25c89bd703e6f7f8bb7bb1cb Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Fri, 12 Nov 2010 19:28:51 +0000 Subject: Improved STLport support (now code compiles fine if STLport is in its own namespace and does #define std), fixed AirPlay SDK compilation git-svn-id: http://pugixml.googlecode.com/svn/trunk@796 99668b35-9821-0410-8761-19e4c4f06640 --- src/pugixml.cpp | 15 ++++++++++----- src/pugixml.hpp | 26 +++++++++++++++++++------- 2 files changed, 29 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 9132d8a..fdb92ea 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -90,6 +90,11 @@ typedef __int32 int32_t; # define DMC_VOLATILE #endif +// In some environments MSVC is a compiler but the CRT lacks certain MSVC-specific features +#if defined(_MSC_VER) && !defined(__S3E__) +# define MSVC_CRT_VERSION _MSC_VER +#endif + using namespace pugi; // Memory allocation @@ -3088,7 +3093,7 @@ namespace // we need to get length of entire file to load it in memory; the only (relatively) sane way to do it is via seek/tell trick xml_parse_status get_file_size(FILE* file, size_t& out_result) { - #if defined(_MSC_VER) && _MSC_VER >= 1400 + #if defined(MSVC_CRT_VERSION) && MSVC_CRT_VERSION >= 1400 // there are 64-bit versions of fseek/ftell, let's use them typedef __int64 length_type; @@ -3194,7 +3199,7 @@ namespace } #endif -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__) +#if defined(MSVC_CRT_VERSION) || defined(__BORLANDC__) || defined(__MINGW32__) FILE* open_file_wide(const wchar_t* path, const wchar_t* mode) { return _wfopen(path, mode); @@ -5608,7 +5613,7 @@ namespace bool is_nan(double value) { - #if defined(_MSC_VER) || defined(__BORLANDC__) + #if defined(MSVC_CRT_VERSION) || defined(__BORLANDC__) return !!_isnan(value); #elif defined(fpclassify) && defined(FP_NAN) return fpclassify(value) == FP_NAN; @@ -5621,7 +5626,7 @@ namespace const char_t* convert_number_to_string_special(double value) { - #if defined(_MSC_VER) || defined(__BORLANDC__) + #if defined(MSVC_CRT_VERSION) || defined(__BORLANDC__) if (_finite(value)) return (value == 0) ? PUGIXML_TEXT("0") : 0; if (_isnan(value)) return PUGIXML_TEXT("NaN"); return PUGIXML_TEXT("-Infinity") + (value > 0); @@ -5664,7 +5669,7 @@ namespace } // gets mantissa digits in the form of 0.xxxxx with 0. implied and the exponent -#if defined(_MSC_VER) && _MSC_VER >= 1400 +#if defined(MSVC_CRT_VERSION) && MSVC_CRT_VERSION >= 1400 void convert_number_to_mantissa_exponent(double value, char* buffer, size_t buffer_size, char** out_mantissa, int* out_exponent) { // get base values diff --git a/src/pugixml.hpp b/src/pugixml.hpp index 78959ac..8e8f3e1 100644 --- a/src/pugixml.hpp +++ b/src/pugixml.hpp @@ -16,7 +16,19 @@ #include "pugiconfig.hpp" +// Include stddef.h for size_t and ptrdiff_t +#include + +// Include exception header for XPath +#if !defined(PUGIXML_NO_XPATH) && !defined(PUGIXML_NO_EXCEPTIONS) +# include +#endif + #ifndef PUGIXML_NO_STL +// cstddef is needed so that we get the 'std' namespace declaration (STLport sometimes makes std a define) +#include + +// Forward declarations for STL classes to reduce include dependencies namespace std { struct bidirectional_iterator_tag; @@ -31,7 +43,14 @@ namespace std #else // Borland C++ compiler has a bug which forces template argument names in forward declarations to be the same as in actual definitions template class allocator; + + // STLport defines char_traits as a class instead of a struct +# ifdef _STLPORT_VERSION + template class char_traits; +# else template struct char_traits; +# endif + template class basic_istream; template class basic_ostream; template class basic_string; @@ -56,11 +75,6 @@ namespace std # endif #endif -// Include exception header for XPath -#if !defined(PUGIXML_NO_XPATH) && !defined(PUGIXML_NO_EXCEPTIONS) -# include -#endif - // If no API is defined, assume default #ifndef PUGIXML_API # define PUGIXML_API @@ -76,8 +90,6 @@ namespace std # define PUGIXML_FUNCTION PUGIXML_API #endif -#include - // Character interface macros #ifdef PUGIXML_WCHAR_MODE # define PUGIXML_TEXT(t) L ## t -- cgit v1.2.3