From 7110b7c5f2311a3183bfa12cb51941aa942b470e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 20 Oct 2023 15:51:23 -0700 Subject: [PATCH] fix return type mismatch when cross-compiling with macos sdk --- src/class.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/class.zig b/src/class.zig index 74a4fe5..d262634 100644 --- a/src/class.zig +++ b/src/class.zig @@ -78,7 +78,14 @@ pub const Class = struct { // only call this function between allocateClassPair and registerClassPair // this adds an Ivar of type `id`. pub fn addIvar(self: Class, name: [:0]const u8) bool { - return c.class_addIvar(self.value, name, @sizeOf(c.id), @alignOf(c.id), "@"); + // The return type is i8 when we're cross compiling, unsure why. + const fn_info = @typeInfo(@TypeOf(c.class_addIvar)).Fn; + const result = c.class_addIvar(self.value, name, @sizeOf(c.id), @alignOf(c.id), "@"); + return switch (fn_info.return_type.?) { + bool => result, + i8 => result == 1, + else => @compileError("unhandled class_addIvar return type"), + }; } };