Skip to content

Commit 22cdd3a

Browse files
MarkKropfclaude
andcommitted
Fix Windows build: undef TWOPI/HALFPI in GuiHandler.cpp
Reverts the NOGDI approach (broke vfw.h for AVI capture) in favor of a targeted fix: undef the wingdi.h TWOPI/HALFPI macros directly in GuiHandler.cpp after the SDL includes. This is the only file where SDL's transitive windows.h include causes math::TWOPI to be macro-expanded. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 41b9a0d commit 22cdd3a

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -431,14 +431,6 @@ if(REPORT_LUANAN)
431431
add_definitions(-DREPORT_LUANAN)
432432
endif()
433433

434-
### MinGW wingdi.h macro suppression
435-
# wingdi.h defines TWOPI/HALFPI macros that conflict with math:: namespace
436-
# constants. NOGDI suppresses wingdi.h while keeping GDI handle types
437-
# (HDC, HWND etc.) available from windef.h.
438-
if(MINGW)
439-
add_definitions(-DNOGDI)
440-
endif()
441-
442434
### streflop
443435
option(ENABLE_STREFLOP "build Spring with streflop support (REQUIRED FOR MULTIPLAYER)" TRUE)
444436

rts/Game/UI/GuiHandler.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@
7171

7272
#include "System/Misc/TracyDefs.h"
7373

74+
// MinGW wingdi.h defines TWOPI/HALFPI macros via transitive windows.h
75+
// includes from SDL headers. Must undef before code uses math::TWOPI.
76+
#ifdef TWOPI
77+
#undef TWOPI
78+
#endif
79+
#ifdef HALFPI
80+
#undef HALFPI
81+
#endif
82+
7483
CONFIG(bool, MiniMapMarker).defaultValue(true).headlessValue(false);
7584
CONFIG(bool, InvertQueueKey).defaultValue(false);
7685

rts/Rendering/AVIGenerator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "System/Misc/NonCopyable.h"
1010

1111
#include <windows.h>
12-
#include <wingdi.h> // Explicitly include for LPBITMAPINFOHEADER (skipped by NOGDI)
1312
#include <vfw.h>
1413

1514
#include <string>

0 commit comments

Comments
 (0)