authorgravatar for liljaanton2001@gmail.comantlilja <liljaanton2001@gmail.com> 2025-07-09 22:50:19+02:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2025-08-15 18:29:06-04:00
log52178d14b080d0bbf5e1fe8ed25ce1c26ea18566
treedcf7b69304888c19ea48880fdb82a724695695d3
parent375bc2d7b53868fbffc7b1b639247bd814dc3efd

Add test for passing extern function to function


1 files changed, 13 insertions(+), 0 deletions(-)

test/behavior/extern.zig+13
...@@ -56,3 +56,16 @@ test "coerce extern function types" {...@@ -56,3 +56,16 @@ test "coerce extern function types" {
5656
57 _ = @as(fn () callconv(.c) ?*u32, c_extern_function);57 _ = @as(fn () callconv(.c) ?*u32, c_extern_function);
58}58}
59
60fn a_function(func: fn () callconv(.c) void) void {
61 _ = func;
62}
63
64test "pass extern function to function" {
65 a_function(struct {
66 extern fn an_extern_function() void;
67 }.an_extern_function);
68 a_function(@extern(*const fn () callconv(.c) void, .{ .name = "an_extern_function" }).*);
69}
70
71export fn an_extern_function() void {}