From b37be4dc0a9f3dbfec318181c48c3c80738e0751 Mon Sep 17 00:00:00 2001 From: Jameson Nash 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 --- 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