#[pre_init]
Expand description
Attribute to mark which function will be called at the beginning of the reset handler.
IMPORTANT: This attribute can appear at most once in the dependency graph.
The function must have the signature of unsafe fn()
.
§Safety
The function will be called before memory is initialized, as soon as possible after reset. Any access of memory, including any static variables, will result in undefined behavior.
Warning: Due to rvalue static promotion static variables may be accessed whenever
taking a reference to a constant. This means that even trivial expressions such as &1
in the
#[pre_init]
function or any code called by it will cause immediate undefined behavior.
Users are advised to only use the #[pre_init]
feature when absolutely necessary as these
constraints make safe usage difficult.
§Examples
#[pre_init]
unsafe fn before_main() {
// do something here
}