From ebf49310b324a8693f540ea9c9ff4a2101c688ca Mon Sep 17 00:00:00 2001 From: fgenesis Date: Wed, 7 Feb 2024 03:26:18 +0100 Subject: [PATCH] compile fixes for clang when c++98 is enforced --- Aquaria/TileMgr.cpp | 5 ++++- BBGE/Precacher.cpp | 15 ++++++++++----- BBGE/TextureMgr.cpp | 2 +- ExternalLibs/minipstdint.h | 39 ++++++++++++++++++++++++++++++++------ 4 files changed, 48 insertions(+), 13 deletions(-) diff --git a/Aquaria/TileMgr.cpp b/Aquaria/TileMgr.cpp index 673aa63..dae41e4 100644 --- a/Aquaria/TileMgr.cpp +++ b/Aquaria/TileMgr.cpp @@ -75,7 +75,10 @@ size_t TileMgr::getNumTiles() const TileStorage::Sizes TileMgr::getStats() const { - TileStorage::Sizes tsz {}; + TileStorage::Sizes tsz; + tsz.collide = 0; + tsz.tiles = 0; + tsz.update = 0; for(size_t i = 0; i < Countof(tilestore); ++i) { TileStorage::Sizes sz = tilestore[i].stats(); diff --git a/BBGE/Precacher.cpp b/BBGE/Precacher.cpp index 1216c5d..ab7d46a 100644 --- a/BBGE/Precacher.cpp +++ b/BBGE/Precacher.cpp @@ -106,12 +106,17 @@ void Precacher::precacheList(const std::string &list, ProgressCallback progress) std::string t; while (std::getline(in, t)) { - while (!t.empty()) + if(!t.empty()) { - if(t.back() == '\r' || t.back() == '\n') // linux doesn't like CRLF, make sure to trim that off - t.pop_back(); - else - break; + size_t i = t.size(); + for( ; i --> 0; ) + { + const char bk = t[i]; + if(!(bk == '\r' || bk == '\n' || bk == ' ' || bk == '\t')) // linux doesn't like CRLF, make sure to trim that off + break; + } + if(i+1 != t.size()) + t.erase(i+1, std::string::npos); } if(!t.empty()) diff --git a/BBGE/TextureMgr.cpp b/BBGE/TextureMgr.cpp index 06fca12..290c429 100644 --- a/BBGE/TextureMgr.cpp +++ b/BBGE/TextureMgr.cpp @@ -198,7 +198,7 @@ void TextureMgr::clearUnused() { if(it->second->refcount() <= 1) { - it = cache.erase(it); + cache.erase(it++); ++done; } else diff --git a/ExternalLibs/minipstdint.h b/ExternalLibs/minipstdint.h index da44697..c4105f6 100644 --- a/ExternalLibs/minipstdint.h +++ b/ExternalLibs/minipstdint.h @@ -8,7 +8,16 @@ #include -#if defined(_MSC_VER) && _MSC_VER < 1600 +#if (defined(__cplusplus) && (__cplusplus+0 > 201103L)) \ +|| (defined(_MSC_VER) && (_MSC_VER+0 > 1600)) \ +|| (defined(__STDC_VERSION__) && (__STDC_VERSION__+0 >= 199901L)) +# if (defined(__cplusplus) && (__cplusplus+0 > 201103L)) +# include +# endif +# include + +#elif defined(_MSC_VER) // older MSVC + #include "SDL_version.h" #if SDL_VERSION_ATLEAST(2, 0, 0) // AQUARIA HACK: Included SDL 1.2 includes define some of these, SDL does not. Avoid conflicts. typedef signed __int8 int8_t; @@ -43,11 +52,29 @@ # define UINT32_C(v) ((uint32_t)v) # define UINT64_C(v) (v ## UI64) # define INT64_C(v) (v ## I64) -#else -# ifdef __cplusplus -# include -# endif -# include +#elif 1 + typedef __uint8_t uint8_t; + typedef __int8_t int8_t; + typedef __uint16_t uint16_t; + typedef __int16_t int16_t; + typedef __uint32_t uint32_t; + typedef __int32_t int32_t; + typedef __uint64_t uint64_t; + typedef __int64_t int64_t; +#elif 0 + typedef unsigned char uint8_t; + typedef signed char int8_t; + typedef unsigned short uint16_t; + typedef signed short int16_t; + typedef unsigned int uint32_t; + typedef signed int int32_t; + typedef unsigned long long uint64_t; + typedef signed long long int64_t; + + // produce compile errors if the sizes aren't right + typedef char _pstdint_testsize16[sizeof(int16_t) == 2]; + typedef char _pstdint_testsize32[sizeof(int32_t) == 4]; + typedef char _pstdint_testsize64[sizeof(int64_t) == 8]; #endif # if !defined (UINT64_MAX)