Skip to main content

ram_fn

Attribute Macro ram_fn 

#[ram_fn]
Expand description

Define a RAM-copyable function with any non-generic signature.

max is the function’s maximum compiled size, in bytes. install relies on it for a compile-time buffer check, but the bound itself (actual code length <= max) is verified only after compilation, by cargo-gb over the linked ROM. A build path that skips that check does not guarantee it, leaving install able to overflow its buffer.

The function becomes a zero-sized handle of the same name, implementing the RamFn trait. For fn inc(), inc.rom() gives the ROM copy and inc.install(buf) copies the code into buf and returns the RAM copy. Both are trait methods, so RamFn has to be in scope.