From 210c9419e4bddd1fe8e9be7cb66de31119fa0d68 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 8 May 2021 16:48:40 -0700 Subject: [PATCH 1/2] Ignore -Wtrigraphs --- src/CMakeLists.txt | 2 ++ src/Makefile.cfg | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 87a0499b6..88ab1cdcb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -604,6 +604,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-absolute-value) endif() +set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-trigraphs) + add_definitions(-DCMAKECONFIG) #add_library(SRB2Core STATIC diff --git a/src/Makefile.cfg b/src/Makefile.cfg index 075cd2d3a..79d332f85 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -209,7 +209,7 @@ endif OLDWFLAGS:=$(WFLAGS) # -W -Wno-unused -WFLAGS=-Wall +WFLAGS=-Wall -Wno-trigraphs ifndef GCC295 #WFLAGS+=-Wno-packed endif From 35244fa736cd2b5d1a35b471ef75cfaaba6a3a2a Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 8 May 2021 16:49:23 -0700 Subject: [PATCH 2/2] Clang: fix -Wimplicit-const-int-float-conversion Some of these integers exceed the precision of float. In that case the number is rounded. The rounding shouldn't matter too much anyway, so just shut the compiler up. --- src/hardware/hw_main.c | 2 +- src/m_random.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e94c637e4..dd633d6fc 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5715,7 +5715,7 @@ static void HWR_DrawSkyBackground(player_t *player) dimensionmultiply = ((float)textures[texturetranslation[skytexture]]->width/256.0f); - v[0].s = v[3].s = (-1.0f * angle) / ((ANGLE_90-1)*dimensionmultiply); // left + v[0].s = v[3].s = (-1.0f * angle) / (((float)ANGLE_90-1.0f)*dimensionmultiply); // left v[2].s = v[1].s = v[0].s + (1.0f/dimensionmultiply); // right (or left + 1.0f) // use +angle and -1.0f above instead if you wanted old backwards behavior diff --git a/src/m_random.c b/src/m_random.c index 481fdb72b..b00eff60f 100644 --- a/src/m_random.c +++ b/src/m_random.c @@ -60,7 +60,7 @@ UINT8 M_RandomByte(void) */ INT32 M_RandomKey(INT32 a) { - return (INT32)((rand()/((unsigned)RAND_MAX+1.0f))*a); + return (INT32)((rand()/((float)RAND_MAX+1.0f))*a); } /** Provides a random integer in a given range. @@ -73,7 +73,7 @@ INT32 M_RandomKey(INT32 a) */ INT32 M_RandomRange(INT32 a, INT32 b) { - return (INT32)((rand()/((unsigned)RAND_MAX+1.0f))*(b-a+1))+a; + return (INT32)((rand()/((float)RAND_MAX+1.0f))*(b-a+1))+a; }