PRPG:

Global_init_slot [upd] Instant

In resource‑constrained and safety‑critical embedded systems, the order of initialization of global objects and hardware peripherals is often critical. The global_init_slot pattern provides a deterministic, link‑time‑arranged array of function pointers or constructor slots that execute before main() . This paper defines global_init_slot , compares it with standard C++ static initialization and POSIX __attribute__((constructor)) , and analyzes its advantages in terms of execution order control, memory footprint, and debuggability. A practical implementation using linker sections is presented.

The global_init_slot pattern is a simple, low‑overhead, and highly deterministic alternative to compiler‑driven static initialization for bare‑metal and RTOS environments. It gives developers explicit control over boot order, reduces reliance on C++ runtime, and produces debuggable symbol tables. While not a universal standard, its implementation using linker sections and attributes is widely portable across ELF‑based toolchains. For new embedded projects where init order matters, adopting global_init_slot as a design pattern can eliminate subtle “static initialization order fiasco” bugs. global_init_slot