Skip to content

main function has to implement wrong type. #21134

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
tbu- opened this issue Jan 14, 2015 · 1 comment
Closed

main function has to implement wrong type. #21134

tbu- opened this issue Jan 14, 2015 · 1 comment

Comments

@tbu-
Copy link
Contributor

tbu- commented Jan 14, 2015

This is under the assumption that main should receive the same arguments and have the same return type as in C if it has the #[start] attribute:

Currently, the #[start] function has to have the type:

fn main(argc: isize, argv: *const *const u8) -> isize;

This is not an accurate translation of the C prototype, it has to be

fn main(argc: c_int, argv: *const *const u8) -> c_int;

And it's even wrong on x86_64, where isize = i64 and c_int = i32.

@huonw
Copy link
Member

huonw commented Jan 14, 2015

Dupe of #20064.

There's no particular reason that we have to match the C types, the Rust compiler just needs to e.g. create a shim function that does the appropriate casts (it's not like the return value of c_int is that correct anyway: e.g. POSIX systems only look at the lower byte).

@huonw huonw closed this as completed Jan 14, 2015
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

No branches or pull requests

2 participants