commit 52178d14b080d0bbf5e1fe8ed25ce1c26ea18566 (tree) parent 375bc2d7b53868fbffc7b1b639247bd814dc3efd Author: antlilja <liljaanton2001@gmail.com> Date: Wed, 9 Jul 2025 22:50:19 +0200 Add test for passing extern function to function Diffstat:
| M | test/behavior/extern.zig | | | 13 | +++++++++++++ |
1 file changed, 13 insertions(+), 0 deletions(-)
diff --git a/test/behavior/extern.zig b/test/behavior/extern.zig @@ -56,3 +56,16 @@ test "coerce extern function types" { _ = @as(fn () callconv(.c) ?*u32, c_extern_function); } + +fn a_function(func: fn () callconv(.c) void) void { + _ = func; +} + +test "pass extern function to function" { + a_function(struct { + extern fn an_extern_function() void; + }.an_extern_function); + a_function(@extern(*const fn () callconv(.c) void, .{ .name = "an_extern_function" }).*); +} + +export fn an_extern_function() void {}