diff options
author | Slava Zakharin <szakharin@nvidia.com> | 2024-04-04 14:23:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-04 14:23:40 -0700 |
commit | 864d2531df8078a5bb49d24383d7219595d23690 (patch) | |
tree | 0c9ac8e1be20f71e3e25a673ed36a3e1052877d3 | |
parent | f5960c168dfe17c7599acea0a7d94a26545f4777 (diff) | |
download | llvm-864d2531df8078a5bb49d24383d7219595d23690.zip llvm-864d2531df8078a5bb49d24383d7219595d23690.tar.gz llvm-864d2531df8078a5bb49d24383d7219595d23690.tar.bz2 |
[flang] Added windows-include.h wrapper to resolve name conflicts. (#87650)
The header file includes windows.h in a mean-and-lean way to avoid
bringing in names that may conflict with Flang code.
-rw-r--r-- | flang/include/flang/Common/windows-include.h | 25 | ||||
-rw-r--r-- | flang/runtime/command.cpp | 4 | ||||
-rw-r--r-- | flang/runtime/execute.cpp | 4 | ||||
-rw-r--r-- | flang/runtime/file.cpp | 3 | ||||
-rw-r--r-- | flang/runtime/lock.h | 4 |
5 files changed, 29 insertions, 11 deletions
diff --git a/flang/include/flang/Common/windows-include.h b/flang/include/flang/Common/windows-include.h new file mode 100644 index 0000000..75ef497 --- /dev/null +++ b/flang/include/flang/Common/windows-include.h @@ -0,0 +1,25 @@ +//===-- include/flang/Common/windows-include.h ------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Wrapper around windows.h that works around the name conflicts. +// +//===----------------------------------------------------------------------===// + +#ifndef FORTRAN_COMMON_WINDOWS_INCLUDE_H_ +#define FORTRAN_COMMON_WINDOWS_INCLUDE_H_ + +#ifdef _WIN32 + +#define WIN32_LEAN_AND_MEAN +#define NOMINMAX + +#include <windows.h> + +#endif // _WIN32 + +#endif // FORTRAN_COMMON_WINDOWS_INCLUDE_H_ diff --git a/flang/runtime/command.cpp b/flang/runtime/command.cpp index fabfe60..b573c5d 100644 --- a/flang/runtime/command.cpp +++ b/flang/runtime/command.cpp @@ -16,9 +16,7 @@ #include <limits> #ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX -#include <windows.h> +#include "flang/Common/windows-include.h" // On Windows GetCurrentProcessId returns a DWORD aka uint32_t #include <processthreadsapi.h> diff --git a/flang/runtime/execute.cpp b/flang/runtime/execute.cpp index c84930c..0f5bc50 100644 --- a/flang/runtime/execute.cpp +++ b/flang/runtime/execute.cpp @@ -16,9 +16,7 @@ #include <future> #include <limits> #ifdef _WIN32 -#define LEAN_AND_MEAN -#define NOMINMAX -#include <windows.h> +#include "flang/Common/windows-include.h" #else #include <signal.h> #include <sys/wait.h> diff --git a/flang/runtime/file.cpp b/flang/runtime/file.cpp index 67764f1..acd5d33d 100644 --- a/flang/runtime/file.cpp +++ b/flang/runtime/file.cpp @@ -17,9 +17,8 @@ #include <stdlib.h> #include <sys/stat.h> #ifdef _WIN32 -#define NOMINMAX +#include "flang/Common/windows-include.h" #include <io.h> -#include <windows.h> #else #include <unistd.h> #endif diff --git a/flang/runtime/lock.h b/flang/runtime/lock.h index 9f27a82..46ca287 100644 --- a/flang/runtime/lock.h +++ b/flang/runtime/lock.h @@ -25,9 +25,7 @@ #if USE_PTHREADS #include <pthread.h> #elif defined(_WIN32) -// Do not define macros for "min" and "max" -#define NOMINMAX -#include <windows.h> +#include "flang/Common/windows-include.h" #else #include <mutex> #endif |