Skip to content

Commit

Permalink
build: globally define NOMINMAX
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fanquake committed Jun 20, 2022
1 parent a09033e commit 58a9601
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 15 deletions.
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,9 @@ case $host in
fi

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

dnl libtool insists upon adding -nostdlib and a list of objects/libs to link against.
dnl That breaks our ability to build dll's with static libgcc/libstdc++/libssp. Override
Expand Down
3 changes: 0 additions & 3 deletions src/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
#endif

#ifdef WIN32
#ifndef NOMINMAX
#define NOMINMAX
#endif
#ifdef FD_SETSIZE
#undef FD_SETSIZE // prevent redefinition compiler warning
#endif
Expand Down
3 changes: 0 additions & 3 deletions src/fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
#include <sys/utsname.h>
#include <unistd.h>
#else
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <codecvt>
#include <limits>
#include <windows.h>
Expand Down
3 changes: 0 additions & 3 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
#include <util/time.h>

#ifdef WIN32
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <shellapi.h>
#include <shlobj.h>
#include <shlwapi.h>
Expand Down
3 changes: 0 additions & 3 deletions src/support/lockedpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
#endif

#ifdef WIN32
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h>
#else
#include <sys/mman.h> // for mmap
Expand Down
3 changes: 0 additions & 3 deletions src/util/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@
#pragma warning(disable:4717)
#endif

#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <codecvt>

#include <io.h> /* for _commit */
Expand Down

0 comments on commit 58a9601

Please sign in to comment.