Skip to content

Commit 44f59ba

Browse files
vtjnashclaude
andauthored
[flang] Fix ISO_C_BINDING type sizes for Windows (#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 Windows-on-ARM-Experiments/mingw-woarm64-build#9 (comment) - 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 msys2/MINGW-packages#16579 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent ba2bd3f commit 44f59ba

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

flang/module/iso_c_binding.f90

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ module iso_c_binding
4343
integer, parameter, public :: &
4444
c_int = c_int32_t, &
4545
c_short = c_int16_t, &
46+
#if defined(_WIN32)
47+
c_long = c_int32_t, &
48+
#else
4649
c_long = c_int64_t, &
50+
#endif
4751
c_long_long = c_int64_t, &
4852
c_signed_char = c_int8_t, &
4953
c_size_t = kind(c_sizeof(1)), &
@@ -74,8 +78,10 @@ module iso_c_binding
7478
integer, parameter, public :: &
7579
c_float = 4, &
7680
c_double = 8, &
77-
#if __x86_64__
81+
#if defined(__x86_64__)
7882
c_long_double = 10
83+
#elif defined(_WIN32) && defined(__aarch64__)
84+
c_long_double = 8
7985
#else
8086
c_long_double = 16
8187
#endif
@@ -117,9 +123,13 @@ module iso_c_binding
117123
c_unsigned_char = c_uint8_t, &
118124
c_unsigned_short = c_uint16_t, &
119125
c_unsigned = c_uint32_t, &
126+
#if defined(_WIN32)
127+
c_unsigned_long = c_uint32_t, &
128+
#else
120129
c_unsigned_long = c_uint64_t, &
121-
c_unsigned_long_long = c_unsigned_long, &
122-
#if __powerpc__
130+
#endif
131+
c_unsigned_long_long = c_uint64_t, &
132+
#if defined(__powerpc__) || defined(_WIN32)
123133
c_uintmax_t = c_uint64_t
124134
#else
125135
c_uintmax_t = c_uint128_t

0 commit comments

Comments
 (0)