Skip to content

[flang] Added windows-include.h wrapper to resolve name conflicts. #87650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions flang/include/flang/Common/windows-include.h
Original file line number Diff line number Diff line change
@@ -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_
4 changes: 1 addition & 3 deletions flang/runtime/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 1 addition & 3 deletions flang/runtime/execute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
3 changes: 1 addition & 2 deletions flang/runtime/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions flang/runtime/lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down