|Just <include> iostream adds 500KB in release mode, executable stripped, to any program using MinGW compiler, even if you don't use anything from it.|
That's insane. I wouldn't expect any increase in file size, but having tested the same thing in MSVS it does appear to happen. That is utterly baffling to me. (Until I thought about it some more, read further down in my post)
MSVS doesn't have near the same numbers though. With full optimizations on I get the following in VS2012 Express:
- Empty main() with no includes, dynamic link to runtime: 7K
- Empty main(), including iostream, dynamic link: 11K
- Empty main(), no includes, static link: 56K
- Empty main(), including iostream, static link: 79K
My only thought is that MinGW's default "Release" settings are poor and you should go over optimization settings manually to make sure they're switched on. Either that or its optimizer sucks, which I highly doubt.
At first I didn't expect adding an unused header to increase filesize at all... then I remembered <iostream> has global variables (cout/cin), which means there is additional code for ctors/dtors being run... and they can't be optimized out due to possible side effects. So therefore it makes sense.
The same test... but including <list> (which has no global objects to my knowledge -- and is what the OP was asking about):
- Empty main(), no includes, dynamic link: 7K
- Empty main(), include list, dynamic link: 7K
- no includes, static link: 56K
- include list, static: 56K
So that makes perfect sense.
The next thing was testing the actual std::list class, as this is what OP was actually asking about. This is trickier because I imagine the compiler might optimize out the class usage entirely... but here's some basic usage:
auto i = foo.begin();
int sum = 0;
for(auto& i : foo)
sum += i;
- Dynamic link = 8K
- Static link = 79K
So I would hardly call that bloated.
|I'll just post the full source right now, It's not much code,|
the program reports itself to be - 1231 lines of code, most of it is file operation etc.
I'll check this out now and see if I can figure out what's up.
For reference, what compiler are you using?
EDIT: err... the link 404s for me. I can't download it.