zig icon indicating copy to clipboard operation
zig copied to clipboard

non `callconv(.C)` function pointers no longer allowed in extern contexts

Open xdBronch opened this issue 1 year ago • 0 comments

Zig Version

0.12

Steps to Reproduce and Observed Behavior

const T = extern struct {
    f: *const fn () void,
};

export fn f(_: *const fn () void) void {}

comptime {
    _ = @as(T, undefined);
}
d.zig:5:13: error: parameter of type '*const fn () void' not allowed in function with calling convention 'C'
export fn f(_: *const fn () void) void {}
            ^~~~~~~~~~~~~~~~~~~~
d.zig:5:13: note: extern function must specify calling convention
d.zig:2:8: error: extern structs cannot contain fields of type '*const fn () void'
    f: *const fn () void,
       ^~~~~~~~~~~~~~~~~
d.zig:2:8: note: extern function must specify calling convention

this worked in 0.11, caused by #17509 see https://github.com/ziglang/zig/issues/17468#issuecomment-2037278370

Expected Behavior

no error

xdBronch avatar May 09 '24 23:05 xdBronch