Skip to content

Change main function to use extern rust instead of C #33

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

Closed
wants to merge 1 commit into from

Conversation

morr0ne
Copy link
Contributor

@morr0ne morr0ne commented Sep 3, 2023

Currently origin requires users of the library to supply a main function with the following definition

extern "C" {
    fn main(argc: c_int, argv: *mut *mut u8, envp: *mut *mut u8) -> c_int;
}

However it is not necessary to use an extern C there since this never crosses any ffi boundary and is always compiled from source. This pr changes this from an extern C to an extern Rust. This allows to omit any extern declarations when writing main since the Rust extern is always implied.

Main function before this change:

#[no_mangle]
extern "C" fn main(argc: i32, argv: *const *const u8) -> i32 {} 

Main function after this change

#[no_mangle] // No mangle is still required since we are still linking from an external library
fn main(argc: i32, argv: *const *const u8) -> i32 {} 

@morr0ne morr0ne changed the title Main main function extern rust instead of C Change main function to use extern rust instead of C Sep 3, 2023
@morr0ne
Copy link
Contributor Author

morr0ne commented Sep 3, 2023

Closed in favor of #34

@morr0ne morr0ne closed this Sep 3, 2023
@morr0ne morr0ne deleted the extern-rust branch September 3, 2023 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant