Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove need to define NOMINMAX on none windows. #1002

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,34 @@ else()
endif()

if(WIN32)
add_definitions(-DWIN32 -D_WINDOWS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(-DWIN32 -D_WINDOWS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DNOMINMAX)
set(COMMON_LIBS winmm)
endif()

if(NOT MSVC)
# GCC and Clang don't check new allocations by default while MSVC does.
message(STATUS "Checking whether compiler supports -fcheck-new")
check_cxx_compiler_flag("-Werror -fcheck-new" HAVE_CHECK_NEW)

if(HAVE_CHECK_NEW)
message(STATUS "yes")
list(APPEND VC_CXX_FLAGS -fcheck-new)
else()
message(STATUS "no")
endif()

# Some platforms default to an unsigned char, this fixes that.
message(STATUS "Checking whether compiler supports -fsigned-char")
check_cxx_compiler_flag("-Werror -fsigned-char" HAVE_SIGNED_CHAR)

if(HAVE_SIGNED_CHAR)
message(STATUS "yes")
list(APPEND VC_CXX_FLAGS -fsigned-char)
else()
message(STATUS "no")
endif()
endif()

set(VANILLA_DEFS "")
set(VANILLA_LIBS "")

Expand Down
5 changes: 3 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
"CMAKE_C_FLAGS_DEBUG": "-g3 -Og",
"CMAKE_CXX_FLAGS_RELEASE": "-O3 -g3 -DNDEBUG",
"CMAKE_C_FLAGS_RELEASE": "-O3 -g3 -DNDEBUG",
"VC_CXX_FLAGS": "-w;-Wwrite-strings;-Werror=write-strings;-fcheck-new;-DNOMINMAX",
"VC_CXX_FLAGS": "-w;-Wwrite-strings;-Werror=write-strings",
"MAP_EDITORTD": "ON",
"MAP_EDITORRA": "ON",
"BUILD_TOOLS": "ON"
Expand Down Expand Up @@ -178,7 +178,7 @@
"CMAKE_C_FLAGS_RELEASE": "-O3 -g -DNDEBUG",
"CMAKE_EXE_LINKER_FLAGS": "-static-libstdc++ -static-libgcc",
"CMAKE_SHARESD_LINKER_FLAGS": "-static-libstdc++ -static-libgcc",
"VC_CXX_FLAGS": "-fpermissive;-w;-Wwrite-strings;-Werror=write-strings;-fcheck-new;-fsigned-char;-DNOMINMAX",
"VC_CXX_FLAGS": "-w;-Wwrite-strings;-Werror=write-strings",
"MAP_EDITORTD": "ON",
"MAP_EDITORRA": "ON",
"BUILD_TOOLS": "ON"
Expand All @@ -199,6 +199,7 @@
"BUILD_VANILLARA": "OFF",
"MAP_EDITORTD": "OFF",
"MAP_EDITORRA": "OFF",
"VC_CXX_FLAGS": "-fpermissive;-w;-Wwrite-strings;-Werror=write-strings",
"BUILD_TOOLS": "OFF"
}
},
Expand Down
2 changes: 1 addition & 1 deletion common/packet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "packet.h"
#include "endianness.h"

#ifdef NOMINMAX
#if !defined _WIN32 || defined NOMINMAX
inline int min(int a, int b)
{
return a < b ? a : b;
Expand Down
2 changes: 1 addition & 1 deletion redalert/jshell.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ template <class T> inline T operator~(T t1)
return ((T)(~(int)t1));
}

#ifdef NOMINMAX
#if !defined _WIN32 || defined NOMINMAX
inline int min(int a, int b)
{
return a < b ? a : b;
Expand Down
2 changes: 1 addition & 1 deletion tiberiandawn/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Map(screen) class heirarchy.
³ InfantryTypeClass AircraftTypeClass
*/

#ifdef NOMINMAX
#if !defined _WIN32 || defined NOMINMAX
inline int min(int a, int b)
{
return a < b ? a : b;
Expand Down
Loading