Skip to content

Commit

Permalink
std.DynLib: compile error if attempt to lookup a function pointer wit…
Browse files Browse the repository at this point in the history
…h an unspecified callconv

fixes ziglang#19841
  • Loading branch information
Pyrolistical committed May 3, 2024
1 parent 20b9b54 commit 721388d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/std/dynamic_library.zig
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ pub const DynLib = struct {
}

pub fn lookup(self: *DynLib, comptime T: type, name: [:0]const u8) ?T {
switch (@typeInfo(T)) {
.Pointer => |pointer| {
switch (@typeInfo(pointer.child)) {
.Fn => |function| {
if (function.calling_convention == .Unspecified) {
@compileError("callconv cannot be .Unspecified for: " ++ @typeName(T));
}
},
else => {},
}
},
else => {},
}
return self.inner.lookup(T, name);
}
};
Expand Down

0 comments on commit 721388d

Please sign in to comment.