[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.
This commit is contained in:
Slava Zakharin 2024-04-04 14:23:40 -07:00 committed by GitHub
parent f5960c168d
commit 864d2531df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 29 additions and 11 deletions

View File

@ -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_

View File

@ -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>

View File

@ -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>

View File

@ -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

View File

@ -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