Skip to main content

main

Attribute Macro main 

#[main]
Available on crate feature bank only.
Expand description

Mark the entry point (bank 0, the root of the call stack).

The runtime calls the entry with no token, so it assumes a GroupZero token and drives banked code directly. Because it is the root, leaving a bank mapped after a call is harmless (the next call switches again).

It expands to #[gb_rt::entry] around the rewritten body, so do not apply that attribute as well, and give the function the signature gb-rt requires: fn() -> !.

§Examples

#[bank::main]
pub fn main() -> ! {
    sound::play(60).drive();    // banked function: driven with `.drive()`
    update(0).drive();          // bank-0 helper: also `.drive()`
    loop {}
}