[PATCH] D85656: [flang][msvc] Teach windows.h not to define min/max macros.

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 10 08:20:08 PDT 2020


Meinersbur created this revision.
Meinersbur added reviewers: DavidTruby, sscalpone, isuruf, klausler, tskeith.
Meinersbur added a project: Flang.
Herald added a reviewer: jdoerfert.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Meinersbur requested review of this revision.

Defining macros for min and max breaks using std::min and std::max. Defining NOMINMAX before including the header stops them from being defined.

See https://web.archive.org/web/20170911092732/https://support.microsoft.com/en-us/help/143208/prb-using-stl-in-windows-program-can-cause-min-max-conflicts for details.

This patch is part of the series to make flang compilable with MS Visual Studio <http://lists.llvm.org/pipermail/flang-dev/2020-July/000448.html>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85656

Files:
  flang/runtime/file.cpp


Index: flang/runtime/file.cpp
===================================================================
--- flang/runtime/file.cpp
+++ flang/runtime/file.cpp
@@ -15,6 +15,7 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #ifdef _WIN32
+#define NOMINMAX
 #include <io.h>
 #include <windows.h>
 #else


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85656.284369.patch
Type: text/x-patch
Size: 290 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200810/e06e5af8/attachment.bin>


More information about the llvm-commits mailing list