From bdf430d6b9d616a1ccb1ddc25269d0bc59bea614 Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Sun, 22 Dec 2024 02:50:51 -0800 Subject: [PATCH] Avoid WORDS_BIGENDIAN conflict with Python Python uses the same macro name internally, and this results in compiler warnings about redefining it. Since we're updating this, we might as well move to using CMake's endianness detection as opposed to relying on macros being defined (or not defined) in system headers because that has proven unreliable in the past. --- CMakeLists.txt | 6 ++++++ core/Stream/hsStream.cpp | 8 ++++---- core/Sys/Platform.h | 6 +----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56c71c884..e5e3097ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,12 @@ cmake_dependent_option( OFF ) +include(TestBigEndian) +test_big_endian(BIG_ENDIAN) +if(BIG_ENDIAN) + add_definitions("-DHS_BIG_ENDIAN") +endif() + set(CMAKE_C_FLAGS_DEBUG "-DDEBUG ${CMAKE_C_FLAGS_DEBUG}") set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG ${CMAKE_CXX_FLAGS_DEBUG}") if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR diff --git a/core/Stream/hsStream.cpp b/core/Stream/hsStream.cpp index 2728699b8..28833fbdb 100644 --- a/core/Stream/hsStream.cpp +++ b/core/Stream/hsStream.cpp @@ -54,7 +54,7 @@ uint16_t hsStream::readShort() void hsStream::readShorts(size_t count, uint16_t* buf) { read(sizeof(uint16_t) * count, buf); -#ifdef WORDS_BIGENDIAN +#ifdef HS_BIG_ENDIAN for (size_t i=0; i