This repository was archived by the owner on Jan 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
This repository was archived by the owner on Jan 24, 2022. It is now read-only.
main() calling convention discrepancy #277
Copy link
Copy link
Closed
Labels
Description
The documentation notes that main()'s signature is expected to be extern "C" fn () -> !. The docs say that users could define main() by using the #[entry] macro on a function, or by manually defining a function with that name and calling convention.
Lines 256 to 257 in ef6c6e6
| //! The unmangled `main` symbol must have signature `extern "C" fn() -> !` or its invocation from | |
| //! `Reset` will result in undefined behavior. |
The documentation conforms with the #[entry] macro implementation, which creates a symbol main() as using C calling conventions:
Lines 100 to 112 in ef6c6e6
| quote!( | |
| #(#cfgs)* | |
| #(#attrs)* | |
| #[doc(hidden)] | |
| #[export_name = "main"] | |
| pub unsafe extern "C" fn #tramp_ident() { | |
| #ident( | |
| #(#resource_args),* | |
| ) | |
| } | |
| #f | |
| ) |
However, in Reset(), we qualify main() as using Rust calling conventions:
Lines 902 to 908 in ef6c6e6
| extern "Rust" { | |
| // This symbol will be provided by the user via `#[entry]` | |
| fn main() -> !; | |
| // This symbol will be provided by the user via `#[pre_init]` | |
| fn __pre_init(); | |
| } |
Should we qualify main() as extern "C" in Reset()?
Reactions are currently unavailable