-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Unable to resolve const ptr to function #2352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Milestone
Comments
https://zig.godbolt.org/z/GaiKrV comptime {
// This should be overriden by a strong definition of a symbol with the same name
@export("func", default_func, @import("builtin").GlobalLinkage.Weak);
}
// Library supplied default version
extern fn default_func() void {
while (true) {}
}
extern fn func() void; // declare symbol to be resolved at link time
export const vector = [](extern fn () void) {
func,
};
// The following is in a different file outside of the package path
comptime {
@export("func", user_func, @import("builtin").GlobalLinkage.Strong);
}
// OR (preferably) export fn func() void {
extern fn user_func() void {
while (true) {
// toggle a pin or something
}
} This is what I'm trying to do really. Am I going about this the wrong way? Is this a separate issue? |
This might be solved with #2174 |
fn square(num: i32) i32 {
return num * num;
}
const vector = [_]usize{
@ptrToInt(square),
};
test {
_ = vector;
} the following yields this error (which seems like a different fn pointer promotion bug)
adding an
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gives error: unable to evaluate constant expression
This works however:
The second form won't allow a function pointer with an address of zero and some entries in the vector table on my armv7em processor I believe need to be zero.
This is blocking my progress on making a user-friendly package for arm development on tiva microcontrollers. I have a workaround, but it requires the user to modify a file in the package. I want them to be able to export a function with the correct signature and have it over ride the weak default definition.
The text was updated successfully, but these errors were encountered: