Or what the hell do #![no_start]
, #![no_main]
, #[lang = "start"]
, #[start]
, and #[main]
do?
Crate Attributes:
#![no_start]
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]
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.
Signature:
fn (rust_main: *u8, argc: int, argv: **u8) -> int;
Function Attributes:
#[start]
Overrides the start lang item. It too is called from the actual entry point (real main). It is only passed argc and argv.
Signature:
fn (argc: int, argv: **u8) -> int;
Equivalent to:
#![no_main]
fn my_start(argc: int, argv: **u8) -> int { … }
#[no_mangle]
extern “C” fn main(argc: int, argv: **u8) -> int {
my_start(argc, argv)
}
#[main]
Lets you have a (rust) main function that isn’t called ‘main’. Is called by the start lang item.
Signature:
fn ();
i.e:
#[main]
fn whatever_I_want_to_call_this() { … }