| author | |
| committer | |
| log | 80882bda59427077c141791178b5680fc346eea0 |
| tree | 014b5afba03f2686b7e804dabe6d1d6b7d5d716f |
| parent | fd6b7b160d1fddf967177cf26704908aa7bf5f12 |
| signature | Commit is signed but in an unrecognized format. |
2 files changed, 2 insertions(+), 3 deletions(-)
lib/std/dynamic_library.zig+1-1| ... | @@ -144,7 +144,7 @@ pub const LinuxDynLib = struct { | ... | @@ -144,7 +144,7 @@ pub const LinuxDynLib = struct { |
| 144 | 144 | ||
| 145 | pub fn lookup(self: *LinuxDynLib, comptime T: type, name: []const u8) ?T { | 145 | pub fn lookup(self: *LinuxDynLib, comptime T: type, name: []const u8) ?T { |
| 146 | if (self.elf_lib.lookup("", name)) |symbol| { | 146 | if (self.elf_lib.lookup("", name)) |symbol| { |
| 147 | return @ptrCast(T, symbol); | 147 | return @intToPtr(T, symbol); |
| 148 | } else { | 148 | } else { |
| 149 | return null; | 149 | return null; |
| 150 | } | 150 | } |
test/standalone/load_dynamic_library/main.zig+1-2| ... | @@ -9,8 +9,7 @@ pub fn main() !void { | ... | @@ -9,8 +9,7 @@ pub fn main() !void { |
| 9 | var lib = try std.DynLib.open(dynlib_name); | 9 | var lib = try std.DynLib.open(dynlib_name); |
| 10 | defer lib.close(); | 10 | defer lib.close(); |
| 11 | 11 | ||
| 12 | const addr = lib.lookup("add") orelse return error.SymbolNotFound; | 12 | const addFn = lib.lookup(extern fn (i32, i32) i32, "add") orelse return error.SymbolNotFound; |
| 13 | const addFn = @intToPtr(extern fn (i32, i32) i32, addr); | ||
| 14 | 13 | ||
| 15 | const result = addFn(12, 34); | 14 | const result = addFn(12, 34); |
| 16 | std.debug.assert(result == 46); | 15 | std.debug.assert(result == 46); |