| 1 | const std = @import("std"); |
| 2 | |
| 3 | pub fn main(init: std.process.Init) !void { |
| 4 | const args = try init.minimal.args.toSlice(init.arena.allocator()); |
| 5 | |
| 6 | const dynlib_name = args[1]; |
| 7 | |
| 8 | var lib = try std.DynLib.open(dynlib_name); |
| 9 | defer lib.close(); |
| 10 | |
| 11 | const AddInts = *const fn (i32, i32) callconv(.c) i32; |
| 12 | const addInts = lib.lookup(AddInts, "addInts").?; |
| 13 | std.debug.assert(addInts(12, 34) == 46); |
| 14 | |
| 15 | const FortyTwo = *const fn () callconv(.c) i32; |
| 16 | const fortyTwo = lib.lookup(FortyTwo, "fortyTwo").?; |
| 17 | std.debug.assert(fortyTwo() == 42); |
| 18 | } |