As stated in this answer, when including iostream
library the binary size gets much larger because the std::cin
, std::cout
, std::cerr
(and maybe more) objects are created thus occupying a lot of memory.
I often compile code for embedded platforms which have strict constraints on memory. After including the iostream
library the binary gets so big that it won't fit into the internal flash memory. That in turn affects the libraries which can be included, because a lot of them include <iostream>
. One of example can be Protobuf
library which I can't use across multiple projects as it includes iostream
.
For those targets, which are run on an embedded platform, I don't need the objects to be created because I won't never use it. The question is: can I somehow prevent from creation of those objects? Is there maybe some other workaround which allows to include libraries which use iostream
and to not increase the binary size so much?