Skip to content

Commit 3594769

Browse files
authored
[ELF] Define NOMINMAX to fix zlib.h caused build failure on Windows (#70368)
On Windows when zlib is enabled, zlib header introduced some Windows headers which defines max as a macro. Since OutputSections.cpp uses std::max with template argument, this causes compilation error. Define macro NOMINMAX to avoid this.
1 parent 7d77bbe commit 3594769

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lld/ELF/OutputSections.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "llvm/Support/Path.h"
2323
#include "llvm/Support/TimeProfiler.h"
2424
#if LLVM_ENABLE_ZLIB
25+
// Avoid introducing max as a macro from Windows headers.
26+
#define NOMINMAX
2527
#include <zlib.h>
2628
#endif
2729
#if LLVM_ENABLE_ZSTD

0 commit comments

Comments
 (0)