Static or static
The keyword static in C and C++ has multiple uses, which are not always well understood.
Summary
This blog unpacks the multiple meanings of the C and C++ keyword static and explains how each use affects embedded software. Readers will learn how static impacts storage duration, linkage, initialization, and memory placement — and what that means for microcontroller and embedded Linux projects.
Key Takeaways
- Differentiate between storage duration and linkage uses of static and when each applies.
- Explain the difference between file-scope static, function-local static, and static class members in C/C++.
- Apply best practices for using static in headers and across translation units to avoid symbol collisions and inflated binaries.
- Diagnose common embedded issues caused by static data: .bss/.data placement, flash vs RAM usage, and initialization order.
- Adopt idioms for safe C++ static initialization (including C++11 thread-safety) and for resource-constrained firmware.
Who Should Read This
Intermediate embedded firmware developers and engineers working in C/C++ on microcontrollers or embedded Linux who want to avoid bugs and memory costs related to the static keyword.
TimelessIntermediate
Related Documents
- Consistent Overhead Byte Stuffing TimelessIntermediate
- PID Without a PhD TimelessIntermediate
- Introduction to Embedded Systems - A Cyber-Physical Systems Approach Still RelevantIntermediate
- Can an RTOS be really real-time? TimelessAdvanced
- Memory Mapped I/O in C TimelessIntermediate








