From d274abdcceb4b92bcfd7b73df74f53209ac6d50a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sun, 31 Jan 2016 12:11:09 +0100 Subject: [PATCH] Fixes for GCC Makes jansson library required as well --- CMakeLists.txt | 10 +++++----- src/core/List.hpp | 4 +++- src/core/Memory.hpp | 6 +++--- src/core/String.cpp | 2 +- src/core/String.hpp | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd2eba5f94..6fd2bdbabf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,7 @@ if (NOT PNG_FOUND) endif (NOT PNG_FOUND) PKG_CHECK_MODULES(ZLIB REQUIRED zlib) +PKG_CHECK_MODULES(JANSSON REQUIRED jansson>=2.7) # Handle creating the rct2 text and data files on OS X and Linux # See details in src/openrct2.c:openrct2_setup_rct2_segment for how the values @@ -143,23 +144,22 @@ else (STATIC) endif (STATIC) if (STATIC) - SET(REQUIREDLIBS ${PNG_STATIC_LIBRARIES} ${ZLIB_STATIC_LIBRARIES}) + SET(REQUIREDLIBS ${PNG_STATIC_LIBRARIES} ${JANSSON_STATIC_LIBRARIES} ${ZLIB_STATIC_LIBRARIES}) else (STATIC) - SET(REQUIREDLIBS ${PNG_LIBRARIES} ${ZLIB_LIBRARIES}) + SET(REQUIREDLIBS ${PNG_LIBRARIES} ${JANSSON_LIBRARIES} ${ZLIB_LIBRARIES}) endif (STATIC) if (NOT DISABLE_HTTP_TWITCH) PKG_CHECK_MODULES(LIBCURL REQUIRED libcurl) - PKG_CHECK_MODULES(JANSSON REQUIRED jansson>=2.7) if (WIN32) # Curl depends on openssl and ws2 in mingw builds, but is not wired up in pkg-config PKG_CHECK_MODULES(SSL REQUIRED openssl) set(WSLIBS ws2_32) endif (WIN32) if (STATIC) - SET(HTTPLIBS ${LIBCURL_STATIC_LIBRARIES} ${JANSSON_STATIC_LIBRARIES} ${SSL_STATIC_LIBRARIES} ${WSLIBS}) + SET(HTTPLIBS ${LIBCURL_STATIC_LIBRARIES} ${SSL_STATIC_LIBRARIES} ${WSLIBS}) else (STATIC) - SET(HTTPLIBS ${LIBCURL_LIBRARIES} ${JANSSON_LIBRARIES} ${SSL_LIBRARIES} ${WSLIBS}) + SET(HTTPLIBS ${LIBCURL_LIBRARIES} ${SSL_LIBRARIES} ${WSLIBS}) endif (STATIC) endif (NOT DISABLE_HTTP_TWITCH) diff --git a/src/core/List.hpp b/src/core/List.hpp index 78706d7a3a..80fdf724f6 100644 --- a/src/core/List.hpp +++ b/src/core/List.hpp @@ -14,6 +14,8 @@ template class List : public std::vector { public: + typedef typename std::vector::const_reference const_reference; + typedef typename std::vector::reference reference; size_t GetCapacity() const { return this->capacity(); } size_t GetCount() const { return this->size(); } const T * GetItems() const { return this->data(); } @@ -54,7 +56,7 @@ public: { for (size_t i = 0; i < this->size(); i++) { - if (_items[i] == item) + if (*this[i] == item) { RemoveAt(i); return true; diff --git a/src/core/Memory.hpp b/src/core/Memory.hpp index 50d9dfbf6a..713422a6d8 100644 --- a/src/core/Memory.hpp +++ b/src/core/Memory.hpp @@ -31,7 +31,7 @@ namespace Memory template T * Reallocate(T * ptr, size_t size) { - if (ptr == NULL) + if (ptr == nullptr) { return (T*)malloc(size); } @@ -44,7 +44,7 @@ namespace Memory template T * ReallocateArray(T * ptr, size_t count) { - if (ptr == NULL) + if (ptr == nullptr) { return (T*)malloc(count * sizeof(T)); } @@ -105,7 +105,7 @@ namespace Memory { for (size_t i = 0; i < count; i++) { - ptr[i]::~T(); + ptr[i].~T(); } Free(ptr); } diff --git a/src/core/String.cpp b/src/core/String.cpp index ca1a7f97a9..d721bf2b24 100644 --- a/src/core/String.cpp +++ b/src/core/String.cpp @@ -60,7 +60,7 @@ namespace String { const utf8 * lastOccurance = nullptr; const utf8 * ch = str; - for (; ch != '\0'; ch++) + for (; *ch != '\0'; ch++) { if (*ch == match) { diff --git a/src/core/String.hpp b/src/core/String.hpp index 7af30db4f4..8708176937 100644 --- a/src/core/String.hpp +++ b/src/core/String.hpp @@ -7,7 +7,7 @@ extern "C" namespace String { - constexpr utf8 * Empty = ""; + constexpr const utf8 * Empty = ""; bool IsNullOrEmpty(const utf8 * str); bool Equals(const utf8 * a, const utf8 * b, bool ignoreCase = false);