[flang-commits] [flang] e3d38b7 - [flang][msvc] Tell windows.h to not define min/max macros.

Michael Kruse via flang-commits flang-commits at lists.llvm.org
Wed Aug 12 12:36:30 PDT 2020


Author: Michael Kruse
Date: 2020-08-12T14:36:21-05:00
New Revision: e3d38b7b88989835d11b9d134482c17655b5a65d

URL: https://github.com/llvm/llvm-project/commit/e3d38b7b88989835d11b9d134482c17655b5a65d
DIFF: https://github.com/llvm/llvm-project/commit/e3d38b7b88989835d11b9d134482c17655b5a65d.diff

LOG: [flang][msvc] Tell windows.h to not define min/max macros.

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 [[ http://lists.llvm.org/pipermail/flang-dev/2020-July/000448.html | make flang compilable with MS Visual Studio ]].

Reviewed By: isuruf

Differential Revision: https://reviews.llvm.org/D85656

Added: 
    

Modified: 
    flang/runtime/file.cpp

Removed: 
    


################################################################################
diff  --git a/flang/runtime/file.cpp b/flang/runtime/file.cpp
index 6823b19e5791..8fc81efe6c93 100644
--- a/flang/runtime/file.cpp
+++ b/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


        


More information about the flang-commits mailing list