Skip to content

Commit 721388d

Browse files
committed
std.DynLib: compile error if attempt to lookup a function pointer with an unspecified callconv
fixes #19841
1 parent 20b9b54 commit 721388d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/std/dynamic_library.zig

+13
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ pub const DynLib = struct {
4040
}
4141

4242
pub fn lookup(self: *DynLib, comptime T: type, name: [:0]const u8) ?T {
43+
switch (@typeInfo(T)) {
44+
.Pointer => |pointer| {
45+
switch (@typeInfo(pointer.child)) {
46+
.Fn => |function| {
47+
if (function.calling_convention == .Unspecified) {
48+
@compileError("callconv cannot be .Unspecified for: " ++ @typeName(T));
49+
}
50+
},
51+
else => {},
52+
}
53+
},
54+
else => {},
55+
}
4356
return self.inner.lookup(T, name);
4457
}
4558
};

0 commit comments

Comments
 (0)