I thought this was a kind of interesting experiment (results included in comments in the file):
Dumb question: In order to run this outside of an IDE, exactly which file(s) would be needed? Just the .exe? or is the incremental linker file also necessary?Dumb question: In order to run this outside of an IDE, exactly which file(s) would be needed? Just the .exe? or is the incremental linker file also necessary?Code:
/*
Testing how unnecessary #includes influence
the size of the compiled file
Compiled in VC++ 2008, here are the file sizes for the executable:
1) completely empty program with no #include: 27KB for .exe; 294KB for linker
2) #include <iostream>: 27KB; 302KB for linker file
3) #include <iostream> and #include <string>: 27KB; 302KB for linker
4) using namespace std; : 27KB; 314KB for linker
5) with both #includes as well as minimal code (no using): 33KB for .exe; 319KB for linker
Conclusion here: #include has no influence on the size of the .exe but only
on the linker file--and even there the influence is pretty small
Only the USE of the libraries increases size of executable.
Programmer: Marshall Farrier
Date: 12/21/09
*/
#include <iostream>
#include <string>
//using namespace std; // for 4)
int main()
{
std::string str = "Hasta la vista!\n"; // added for 5)
std::cout << str; // added for 5)
return 0;
}