Skip to content

Commit 0e38f72

Browse files
committed
Define different struct size for APValue on Windows (thanks @Sahnvour)
1 parent 247e567 commit 0e38f72

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src-self-hosted/clang.zig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const builtin = @import("builtin");
2+
13
pub const struct_ZigClangAPSInt = @OpaqueType();
24
pub const struct_ZigClangAPFloat = @OpaqueType();
35
pub const struct_ZigClangASTContext = @OpaqueType();
@@ -938,7 +940,7 @@ pub const struct_ZigClangExprEvalResult = extern struct {
938940

939941
pub const struct_ZigClangAPValue = extern struct {
940942
Kind: ZigClangAPValue_ValueKind,
941-
Data: [68]u8, // TODO: is there a way to statically assert that this matches the .h?
943+
Data: if (builtin.os == .windows) [52]u8 else [68]u8,
942944
};
943945

944946
pub const ZigClangAPValue_ValueKind = extern enum {

src/zig_clang.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ enum ZigClangAPValue_ValueKind {
4747

4848
struct ZigClangAPValue {
4949
enum ZigClangAPValue_ValueKind Kind;
50-
char Data[68]; // experimentally-derived size of clang::APValue::DataType
50+
// experimentally-derived size of clang::APValue::DataType
51+
#ifdef _WIN32
52+
char Data[52];
53+
#else
54+
char Data[68];
55+
#endif
5156
};
5257

5358
struct ZigClangExprEvalResult {

0 commit comments

Comments
 (0)