C++ Reduce Binary Size

12 Feb 2025

[ c++  coding  development  performance  template  ]

Note

Heap allocations to shrink your binary?

Static storage duration can increase the binary size

Object initialization

Member ordering

Special member functions

Where to default ?

Not declared move operations might hurt you

virtual functions

Use minimal templates

Extern templates

Avoid bloaty class templates

Passing functions around

constexpr functions

Compiler and linker flags

RTTI

Exceptions

Takeaways

References