4 ms·
As an embedded programmer working on small micros I make every single function static (including third party code, which I modify and bring into the source tree
by sdfdf4434r34r 5y ago
As an embedded programmer working on small micros I make every single function static (including third party code, which I modify and bring into the source tree and curate myself), gives you global/link time optimizations and dead code elimination for free, leads to better code even at -O0, -Og and -O1, static const configuration structs/values gets optimized away, and so on.
Really wish it was the default.
- deleted 5y ago[deleted]
- kevin_thibedeau 5y agoIt also gives you a nice private namespace for the translation unit so you can confidently modify any of the static objects without concern for impacting external code. I once had a gray beard chew me out over changing a function signature when revising things. I had to point out politely that it was static and that anyone who managed to link to the function had to be breaking a lot of rules to do so.