Skip to content

Commit

Permalink
Remove need to define NOMINMAX on none windows.
Browse files Browse the repository at this point in the history
This is a quick fix, a better solution is to move to using std::min/std::max that will require a larger refactor.
  • Loading branch information
OmniBlade committed Jun 15, 2024
1 parent 2de948c commit 499cec5
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 47 deletions.
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
4 changes: 2 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 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
84 changes: 42 additions & 42 deletions tiberiandawn/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,56 +39,56 @@
Map(screen) class heirarchy.
MapeditClass(most derived class)-- scenario editor
³ MouseClass-- handles mouse animation and display control
³ ScrollClass-- map scroll handler
³ HelpClass-- pop
MouseClass-- handles mouse animation and display control
ScrollClass-- map scroll handler
HelpClass-- pop
- up help text handler
³ TabClass-- file folder tab screen mode control dispatcher
³ SidebarClass-- displays and controls construction list sidebar
³ PowerClass-- display power production
TabClass-- file folder tab screen mode control dispatcher
SidebarClass-- displays and controls construction list sidebar
PowerClass-- display power production
/ consumption bargraph
³ RadarClass-- displays and controls radar map
³ DisplayClass-- general tactical map display handler
³ MapClass-- general tactical map data handler
³ GScreenClass(pure virtual base class)-- generic screen control
RadarClass-- displays and controls radar map
DisplayClass-- general tactical map display handler
MapClass-- general tactical map data handler
GScreenClass(pure virtual base class)-- generic screen control
AbstractClass
³
³
³
³ ObjectClass
³
ÚÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄ¿
AnimClass ³ TemplateClass ³ ÃÄ FuseClass ³ TerrainClass
³ ³ ÃÄ FlyClass ³
³ ³ BulletClass ³ OverlayClass MissionClass SmudgeClass
³ RadioClass
³
ÃÄ CrewClass
ÃÄ FlasherClass
ÃÄ StageClass
ÃÄ CargoClass TechnoClass
³
ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ FootClass BuildingClass
³
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ DriveClass InfantryClass ÃÄ FlyClass
³ AircraftClass TurretClass
³ TarComClass
³ UnitClass
ObjectClass
����������������������������������������������������������������Ŀ
AnimClass TemplateClass �� FuseClass TerrainClass
�� FlyClass
BulletClass OverlayClass MissionClass SmudgeClass
RadioClass
�� CrewClass
�� FlasherClass
�� StageClass
�� CargoClass TechnoClass
�����������������������������������������������������Ŀ FootClass BuildingClass
����������������������������Ŀ DriveClass InfantryClass �� FlyClass
AircraftClass TurretClass
TarComClass
UnitClass
AbstractTypeClass
³ ObjectTypeClass
³
ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³ ³ ³ ³ TechnoTypeClass ³ ³ ³
³ BulletTypeClass ³ ³
³ TemplateTypeClass ³
ÚÄÄÄÄÄÄÄÄÁÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ TerrainTypeClass
³ ³ ³ ³ UnitTypeClass ³ BuildingTypeClass ³
³ InfantryTypeClass AircraftTypeClass
ObjectTypeClass
�����������������������������������������������������Ŀ
TechnoTypeClass
BulletTypeClass
TemplateTypeClass
�����������������������������������������Ŀ TerrainTypeClass
UnitTypeClass BuildingTypeClass
InfantryTypeClass AircraftTypeClass
*/

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

0 comments on commit 499cec5

Please sign in to comment.