-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Description
With 0.6.0, @ptrToInt() surprisingly cannot be used as a constant expression:
The contents of the aforementioned function_table.zig minimal reproduction case:
const std = @import("std");
const testing = std.testing;
export fn my_func() void {}
const ExportedFunction = struct {
name: []const u8,
ptr: usize, // function types vary
};
const functions = [_]ExportedFunction {
.{.name = "my_func", .ptr = @ptrToInt(&my_func)},
};
test "reproduce error: unable to evaluate constant expression" {
testing.expect(functions[0].ptr != 0);
}
By the way, in case there's any better way to create a function lookup table storing function pointers (with varying function type signatures) to exported functions, I'm all ears...
thejay95 and christopher-hesse
Metadata
Metadata
Assignees
Labels
No labels
