mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
17 lines
457 B
Zig
17 lines
457 B
Zig
const std = @import("std");
|
|
|
|
pub fn main(init: std.process.Init) !void {
|
|
const args = try init.minimal.args.toSlice(init.arena.allocator());
|
|
|
|
const dynlib_name = args[1];
|
|
|
|
var lib = try std.DynLib.open(dynlib_name);
|
|
defer lib.close();
|
|
|
|
const Add = *const fn (i32, i32) callconv(.c) i32;
|
|
const addFn = lib.lookup(Add, "add") orelse return error.SymbolNotFound;
|
|
|
|
const result = addFn(12, 34);
|
|
std.debug.assert(result == 46);
|
|
}
|