EmbeddedRelated.com
Static or static

Static or static

Colin Walls
TimelessIntermediate

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

Topics

Firmware DesignBare-Metal ProgrammingEmbedded LinuxRTOS

Related Documents