[flang-commits] [flang] [flang] Fix ISO_C_BINDING type sizes for Windows (PR #172034)
Jameson Nash via flang-commits
flang-commits at lists.llvm.org
Fri Dec 12 08:13:30 PST 2025
https://github.com/vtjnash created https://github.com/llvm/llvm-project/pull/172034
Fix several ISO_C_BINDING type parameters for Windows compatibility:
- c_long/c_unsigned_long: Use 32-bit on Windows (LLP64 data model)
- c_long_double: Use 64-bit (kind=8) on Windows ARM64
https://github.com/Windows-on-ARM-Experiments/mingw-woarm64-build/issues/9#issuecomment-2573385824
- c_unsigned_long_long: Explicitly use c_uint64_t instead of depending on c_unsigned_long
- c_uintmax_t: Use 64-bit on Windows (consistent with MSVC/MinGW)
Fixes issue reported in https://github.com/msys2/MINGW-packages/pull/16579
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply at anthropic.com>
>From b37be4dc0a9f3dbfec318181c48c3c80738e0751 Mon Sep 17 00:00:00 2001
From: Jameson Nash <vtjnash at gmail.com>
Date: Fri, 12 Dec 2025 11:06:43 -0500
Subject: [PATCH] [flang] Fix ISO_C_BINDING type sizes for Windows
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fix several ISO_C_BINDING type parameters for Windows compatibility:
- c_long/c_unsigned_long: Use 32-bit on Windows (LLP64 data model)
- c_long_double: Use 64-bit (kind=8) on Windows ARM64
https://github.com/Windows-on-ARM-Experiments/mingw-woarm64-build/issues/9#issuecomment-2573385824
- c_unsigned_long_long: Explicitly use c_uint64_t instead of
depending on c_unsigned_long
- c_uintmax_t: Use 64-bit on Windows (consistent with MSVC/MinGW)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply at anthropic.com>
---
flang/module/iso_c_binding.f90 | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/flang/module/iso_c_binding.f90 b/flang/module/iso_c_binding.f90
index 8e3f78cea51b7..114588bbecdbd 100644
--- a/flang/module/iso_c_binding.f90
+++ b/flang/module/iso_c_binding.f90
@@ -43,7 +43,11 @@ module iso_c_binding
integer, parameter, public :: &
c_int = c_int32_t, &
c_short = c_int16_t, &
+#if defined(_WIN32)
+ c_long = c_int32_t, &
+#else
c_long = c_int64_t, &
+#endif
c_long_long = c_int64_t, &
c_signed_char = c_int8_t, &
c_size_t = kind(c_sizeof(1)), &
@@ -76,6 +80,8 @@ module iso_c_binding
c_double = 8, &
#if __x86_64__
c_long_double = 10
+#elif defined(_WIN32) && defined(__aarch64__)
+ c_long_double = 8
#else
c_long_double = 16
#endif
@@ -117,9 +123,13 @@ module iso_c_binding
c_unsigned_char = c_uint8_t, &
c_unsigned_short = c_uint16_t, &
c_unsigned = c_uint32_t, &
+#if defined(_WIN32)
+ c_unsigned_long = c_uint32_t, &
+#else
c_unsigned_long = c_uint64_t, &
- c_unsigned_long_long = c_unsigned_long, &
-#if __powerpc__
+#endif
+ c_unsigned_long_long = c_uint64_t, &
+#if __powerpc__ || defined(_WIN32)
c_uintmax_t = c_uint64_t
#else
c_uintmax_t = c_uint128_t
More information about the flang-commits
mailing list