Don't even try to '#include <iostream>' in your embedded project...



TLDR: inluding <iostream> initializes std::in and out before main. This did cost in the firmware were I spotted it 100kb. It could not be optimized out and no functions were used. Just dead flash :0

...if you need to care about flash :)

Choosing the right flash and RAM size at the beginning of a product is key, since the hardware for an MVP will often be delivered with possible full functionality. Sotware or firmware at the inital selling point on the other hand is the culprit for the M in minimal viable product. Enabling the hardware at first with essential functionality, and later with future updates to it's full capability. Maybe your product is lucky and does not need to care about cost and has microncontrollers available with more then enough memory. It still ia a risk, estimating the final memory requirements of firmware before implementing it, it is tricky. Maybe there is no definite feature set known at the beginning anyway, requirement come, go and change.

So many products I worked on were in their late product lifecycle short on one of these to memories. At that point the team searched and fought for every couple of 100 bytes often. So when something in the kilobytes can be freed it can be a product changing situation, if the current hardware can yield the compute for another product iteration or a new controller or even hardware design is necessarry.

What the hell do we use moneypunct for? - Nothing.

Througing the firmware at puncover #i saw a lot of C++ std objects taking up flash. Moneypunct functions where the weirdest to me, because I saw no possible way we needed this kind of formating.

function of moneypunct included

I found the answer and interesting comments in this SO question. Since std::io initialization is done and used before main... sometimes I think the compiler optimizes so much, like it removes unused symbols. But not in this case.

You can imagine what finding a whopping 100kB by removing only one trivial include fells like - it was a very nice work day :)

About
Platz für meine Notizen und Gedanken