Skip to content

Commit 58a9601

Browse files
committed
build: globally define NOMINMAX
Define (and document) `NOMINMAX` once, rather than across multiple source files. Defining this prevents the definition of min/max macros when using mingw-w64, which may conflict with unprefixed std::min/max usage. While that might not be the case for us, we'd always prefer to use the standard library in any case. For example: https://github.com/mingw-w64/mingw-w64/blob/73cadc06c62c6af5faf76f64ef08e684b48de48c/mingw-w64-headers/include/ntdef.h#L289-L300
1 parent a09033e commit 58a9601

File tree

6 files changed

+3
-15
lines changed

6 files changed

+3
-15
lines changed

configure.ac

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,9 @@ case $host in
710710
fi
711711

712712
CORE_CPPFLAGS="$CORE_CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -D_WIN32_WINNT=0x0601 -D_WIN32_IE=0x0501 -DWIN32_LEAN_AND_MEAN"
713+
dnl Prevent the definition of min/max macros.
714+
dnl We always want to use the standard library.
715+
CORE_CPPFLAGS="$CORE_CPPFLAGS -DNOMINMAX"
713716

714717
dnl libtool insists upon adding -nostdlib and a list of objects/libs to link against.
715718
dnl That breaks our ability to build dll's with static libgcc/libstdc++/libssp. Override

src/compat.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
#endif
1212

1313
#ifdef WIN32
14-
#ifndef NOMINMAX
15-
#define NOMINMAX
16-
#endif
1714
#ifdef FD_SETSIZE
1815
#undef FD_SETSIZE // prevent redefinition compiler warning
1916
#endif

src/fs.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
#include <sys/utsname.h>
1313
#include <unistd.h>
1414
#else
15-
#ifndef NOMINMAX
16-
#define NOMINMAX
17-
#endif
1815
#include <codecvt>
1916
#include <limits>
2017
#include <windows.h>

src/qt/guiutil.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
#include <util/time.h>
2525

2626
#ifdef WIN32
27-
#ifndef NOMINMAX
28-
#define NOMINMAX
29-
#endif
3027
#include <shellapi.h>
3128
#include <shlobj.h>
3229
#include <shlwapi.h>

src/support/lockedpool.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
#endif
1111

1212
#ifdef WIN32
13-
#ifndef NOMINMAX
14-
#define NOMINMAX
15-
#endif
1613
#include <windows.h>
1714
#else
1815
#include <sys/mman.h> // for mmap

src/util/system.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@
6262
#pragma warning(disable:4717)
6363
#endif
6464

65-
#ifndef NOMINMAX
66-
#define NOMINMAX
67-
#endif
6865
#include <codecvt>
6966

7067
#include <io.h> /* for _commit */

0 commit comments

Comments
 (0)