Skip to content

Commit 2da9e00

Browse files
LemonBoyandrewrk
authored andcommitted
Add explanation about weird clang behavior on windows
1 parent 1dc25d7 commit 2da9e00

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

test/translate_c.zig

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,21 +1471,25 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
14711471
\\}
14721472
});
14731473

1474-
cases.add("type referenced struct",
1475-
\\struct Foo {
1476-
\\ struct Bar{
1477-
\\ int b;
1478-
\\ };
1479-
\\ struct Bar c;
1480-
\\};
1481-
, &[_][]const u8{
1482-
\\pub const struct_Bar = extern struct {
1483-
\\ b: c_int,
1484-
\\};
1485-
\\pub const struct_Foo = extern struct {
1486-
\\ c: struct_Bar,
1487-
\\};
1488-
});
1474+
if (builtin.os != .windows) {
1475+
// When clang uses the <arch>-windows-none triple it behaves as MSVC and
1476+
// interprets the inner `struct Bar` as an anonymous structure
1477+
cases.add("type referenced struct",
1478+
\\struct Foo {
1479+
\\ struct Bar{
1480+
\\ int b;
1481+
\\ };
1482+
\\ struct Bar c;
1483+
\\};
1484+
, &[_][]const u8{
1485+
\\pub const struct_Bar = extern struct {
1486+
\\ b: c_int,
1487+
\\};
1488+
\\pub const struct_Foo = extern struct {
1489+
\\ c: struct_Bar,
1490+
\\};
1491+
});
1492+
}
14891493

14901494
cases.add("undefined array global",
14911495
\\int array[100] = {};

0 commit comments

Comments
 (0)