[llvm] [Support] On Windows, silence FARPROC casts (PR #191563)
Alexandre Ganea via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 10 15:55:54 PDT 2026
https://github.com/aganea created https://github.com/llvm/llvm-project/pull/191563
When building with clang-cl 19, this was generating:
```
warning: cast from 'FARPROC' ... converts to incompatible function type
[-Wcast-function-type-mismatch]
```
>From f8422c67c22ab6e3bdee9942b91c4dcd217db968 Mon Sep 17 00:00:00 2001
From: Alexandre Ganea <aganea at havenstudios.com>
Date: Fri, 10 Apr 2026 17:44:53 -0400
Subject: [PATCH] [Support] On Windows, silence FARPROC casts
When building with clang-cl 19, this was generating:
```
warning: cast from 'FARPROC' ... converts to incompatible function type
[-Wcast-function-type-mismatch]
```
---
llvm/lib/Support/Windows/Path.inc | 4 ++--
llvm/lib/Support/Windows/Threading.inc | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index 5a70a030adf73..7161af15046ab 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -1199,8 +1199,8 @@ void mapped_file_region::willNeedImpl() {
llvm::sys::windows::loadSystemModuleSecure(L"kernel32.dll");
if (!kernelM)
return nullptr;
- return (PrefetchVirtualMemory_t)::GetProcAddress(kernelM,
- "PrefetchVirtualMemory");
+ return (PrefetchVirtualMemory_t)(void *)::GetProcAddress(
+ kernelM, "PrefetchVirtualMemory");
}();
if (pfnPrefetchVirtualMemory) {
MEMORY_RANGE_ENTRY Range{Mapping, Size};
diff --git a/llvm/lib/Support/Windows/Threading.inc b/llvm/lib/Support/Windows/Threading.inc
index 26dabee1bd6a4..9186e277ba550 100644
--- a/llvm/lib/Support/Windows/Threading.inc
+++ b/llvm/lib/Support/Windows/Threading.inc
@@ -117,8 +117,8 @@ llvm::set_thread_priority(ThreadPriority Priority) {
_In_reads_bytes_(ThreadInformationSize) PVOID ThreadInformation,
ULONG ThreadInformationSize);
static const auto pfnSetThreadInformation =
- (SetThreadInformation_t)::GetProcAddress(kernelM,
- "SetThreadInformation");
+ (SetThreadInformation_t)(void *)::GetProcAddress(
+ kernelM, "SetThreadInformation");
if (pfnSetThreadInformation) {
auto setThreadInformation = [](ULONG ControlMaskAndStateMask) {
THREAD_POWER_THROTTLING_STATE state{};
More information about the llvm-commits
mailing list