You are here

Reducing binary size in C++ projects | Cypress Semiconductor

Reducing binary size in C++ projects

Summary: 0 Replies, Latest post by scutifer on 29 Sep 2014 11:26 PM PDT
Verified Answers: 0
Log in to post new comments.
scutifer's picture
Cypress Employee
134 posts

If you want to reduce binary size in C++ projects, one of the most effective ways is to not use exceptions. And if you're not using them, you can tell the compiler to remove a lot of the backend code by specifing -fno-exceptions while compiling. Refer the GCC manual for details.


Unfortunately, some exception code is still retained as the new operator will throw bad_alloc if it fails to allocate storage. You can override new (and new[]) and delete (and also delete[]) to just do malloc and free. This removes the exception handling code and results in a much smaller binary.


See this link for details on this and a few other tricks.


Post any other ideas you guys have here to reduce binary size.


Log in to post new comments.