Skip to content

Instantly share code, notes, and snippets.

Last active May 26, 2022 17:57
What would you like to do?

Or what the hell do #![no_start], #![no_main], #[lang = "start"], #[start], and #[main] do?

Crate Attributes:


Disable automatically linking in the native crate and thus the default start lang item.

Which means you'll probably need one of: #![no_main], #![lang = “start”] or #[start] instead

Note: #![no_std] implies #![no_start].


No main (entrypoint) function. You may want this for example if you're linking with something that insists on providing main like SDL.

Lang Item

#[lang = “start”]

The function called from the actual entry point (real main). It is passed argc, argv and a pointer to the user’s main function (i.e the rust main function or whatever is marked with #[main]).

The default one in libnative sets up the runtime then calls your main.


fn (rust_main: *u8, argc: int, argv: **u8) -> int;

Function Attributes:


Overrides the start lang item. It too is called from the actual entry point (real main). It is only passed argc and argv.


fn (argc: int, argv: **u8) -> int;

Equivalent to:


fn my_start(argc: int, argv: **u8) -> int {}

externCfn main(argc: int, argv: **u8) -> int {
    my_start(argc, argv)


Lets you have a (rust) main function that isn’t called ‘main’. Is called by the start lang item.


fn ();


fn whatever_I_want_to_call_this() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment