Merge pull request #8483 from Robyt3/Building-Force-Signed-Char

Force default `char` to be `signed` on all architectures
This commit is contained in:
heinrich5991 2024-06-11 21:56:28 +00:00 committed by GitHub
commit eab49abce2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View file

@ -291,11 +291,10 @@ if(NOT MSVC AND NOT HAIKU)
add_cxx_compiler_flag_if_supported(OUR_FLAGS -ffloat-store)
endif()
# This is needed to get the server to correctly display special characters
# on ARM systems.
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64")
add_cxx_compiler_flag_if_supported(OUR_FLAGS -fsigned-char)
endif()
# We assume that char is signed in various places in the code. In particular,
# the Str.StrToInts test will fail when char is not signed and names containing
# special characters will be displayed incorrectly on servers.
add_cxx_compiler_flag_if_supported(OUR_FLAGS -fsigned-char)
# Don't insert timestamps into PEs to keep the build reproducible.
if(TARGET_OS STREQUAL "windows")

View file

@ -9,6 +9,8 @@
#include <base/system.h>
#include <engine/shared/config.h>
#include <limits>
const char *CTuningParams::ms_apNames[] =
{
#define MACRO_TUNING_PARAM(Name, ScriptName, Value, Description) #ScriptName,
@ -63,6 +65,8 @@ float CTuningParams::GetWeaponFireDelay(int Weapon) const
}
}
static_assert(std::numeric_limits<char>::is_signed, "char must be signed for StrToInts to work correctly");
void StrToInts(int *pInts, size_t NumInts, const char *pStr)
{
dbg_assert(NumInts > 0, "StrToInts: NumInts invalid");