diff options
-rw-r--r-- | src/c.zig | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -393,9 +393,13 @@ const LazyStatus = enum { failed, }; -pub fn dlsym(comptime Type: type, comptime name: [:0]const u8) ?*const Type { +pub fn dlsym(comptime Type: type, comptime name: [:0]const u8) ?Type { + if (comptime @typeInfo(Type) != .Pointer) { + @compileError("dlsym must be a pointer type (e.g. ?const *fn()). Received " ++ @typeName(Type) ++ "."); + } + const Wrapper = struct { - pub var function: *const Type = undefined; + pub var function: Type = undefined; pub var loaded: LazyStatus = LazyStatus.pending; }; @@ -407,7 +411,7 @@ pub fn dlsym(comptime Type: type, comptime name: [:0]const u8) ?*const Type { const result = std.c.dlsym(RTLD_DEFAULT, name); if (result) |ptr| { - Wrapper.function = bun.cast(*const Type, ptr); + Wrapper.function = bun.cast(Type, ptr); Wrapper.loaded = .loaded; return Wrapper.function; } else { |