
2008/10/15 Joel Falcou <joel.falcou@u-psud.fr>:
Beman Dawes a écrit :
IIRC, <iostream> is the only standard library header that costs something to include even if the translation unit doesn't actually use it. That's because of the standard stream objects, cin, cout, etc.
Exactly and that's those only objects that skyrocket SPE binary size it seems.
I've noticed on another embedded platform that including the iostream libraries the binary more than doubles, in part because the linker only links in whole objects and each object refers to other parts that aren't functionally used, but are used based on the object references. In particular, it includes a lot of locale stuff that won't have any use on an embedded platform (since it's usually logging) but it'll be linked in anyway. On an embedded system with 1M of memory, eating 80k with iostreams is unacceptable, especially when it uses most of it for unused references. Using a better linker sounds great, but most embedded systems are hardlocked to whatever the system vendor gives you. In case of elf objects, they don't contain enough information to leave out unused symbols unless your compiler separates all symbols into a section per symbol, which it doesn't do by default. Given that the logging is optional (and probably pointless on an embedded system) #ifdeffing out the iostream header seems right.