I recently saw a user hit the "comptime call of extern function" error, and get confused because they didn't know why the scope was `comptime`. So, use `explainWhyBlockIsComptime` on this and related errors to add all the relevant notes. The added test case shows the motivating situation.
16 lines
353 B
Zig
16 lines
353 B
Zig
const x = @extern(*const fn () callconv(.c) void, .{ .name = "foo" });
|
|
|
|
export fn entry0() void {
|
|
comptime x();
|
|
}
|
|
|
|
export fn entry1() void {
|
|
@call(.always_inline, x, .{});
|
|
}
|
|
|
|
// error
|
|
//
|
|
// :4:15: error: comptime call of extern function
|
|
// :4:5: note: 'comptime' keyword forces comptime evaluation
|
|
// :8:5: error: inline call of extern function
|