aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvan Haas <evan@lagerdata.com>2022-07-25 09:53:40 -0700
committerVeikka Tuominen <git@vexu.eu>2022-07-27 14:03:08 +0300
commit7ba1f9bfb52a1f6fa776eeafb45790331be4388f (patch)
treee893b174fc9b7e88ea15190f75e05753b315e940 /lib
parentc8c798685f3a7d6454bc06d5f47531ad6f615eb5 (diff)
downloadzig-7ba1f9bfb52a1f6fa776eeafb45790331be4388f.tar.gz
zig-7ba1f9bfb52a1f6fa776eeafb45790331be4388f.zip
translate-c: take address of functions before passing them to @ptrToInt
Fixes #12194
Diffstat (limited to 'lib')
-rw-r--r--lib/std/zig/c_translation.zig4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/std/zig/c_translation.zig b/lib/std/zig/c_translation.zig
index d64c2b1324..8a2086e9ad 100644
--- a/lib/std/zig/c_translation.zig
+++ b/lib/std/zig/c_translation.zig
@@ -36,6 +36,9 @@ pub fn cast(comptime DestType: type, target: anytype) DestType {
.Int => {
return castInt(DestType, target);
},
+ .Fn => {
+ return castInt(DestType, @ptrToInt(&target));
+ },
else => {},
}
},
@@ -45,6 +48,7 @@ pub fn cast(comptime DestType: type, target: anytype) DestType {
}
@compileError("cast to union type '" ++ @typeName(DestType) ++ "' from type '" ++ @typeName(SourceType) ++ "' which is not present in union");
},
+ .Bool => return cast(usize, target) != 0,
else => {},
}
return @as(DestType, target);