From 30df38f926d20e69a4724afdd73157669616f32b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Thu, 7 Dec 2023 20:36:30 +0100 Subject: [PATCH] Add compile time errors for unsupported endianness We support little and big endian but not PDP endian (Middle-endian). Define endianness as string `CONF_ARCH_ENDIAN_STRING` to avoid conditional compilation when printing endianness. --- src/base/detect.h | 8 ++++++++ src/engine/shared/engine.cpp | 9 +-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/base/detect.h b/src/base/detect.h index 90eeeae78..8bceed086 100644 --- a/src/base/detect.h +++ b/src/base/detect.h @@ -195,4 +195,12 @@ #define CONF_ARCH_STRING "unknown" #endif +#if defined(CONF_ARCH_ENDIAN_LITTLE) +#define CONF_ARCH_ENDIAN_STRING "little endian" +#elif defined(CONF_ARCH_ENDIAN_BIG) +#define CONF_ARCH_ENDIAN_STRING "big endian" +#else +#error "Unsupported endianness" +#endif + #endif diff --git a/src/engine/shared/engine.cpp b/src/engine/shared/engine.cpp index 259c28523..7ab141ebb 100644 --- a/src/engine/shared/engine.cpp +++ b/src/engine/shared/engine.cpp @@ -49,15 +49,8 @@ public: str_copy(m_aAppName, pAppname); if(!Test) { - // dbg_msg("engine", "running on %s-%s-%s", CONF_FAMILY_STRING, CONF_PLATFORM_STRING, CONF_ARCH_STRING); -#ifdef CONF_ARCH_ENDIAN_LITTLE - dbg_msg("engine", "arch is little endian"); -#elif defined(CONF_ARCH_ENDIAN_BIG) - dbg_msg("engine", "arch is big endian"); -#else - dbg_msg("engine", "unknown endian"); -#endif + dbg_msg("engine", "arch is %s", CONF_ARCH_ENDIAN_STRING); char aVersionStr[128]; if(os_version_str(aVersionStr, sizeof(aVersionStr)))