I have a simple piece of c++ code:
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
When I generate the assembly of this code I get a huge assembly file which I presume is compilation of the standard library. Why does this happen and how can I prevent it?
Much of the standard library is made up of templates. When you use a template it gets specialized for your use and the specialization will be part of your binary. This can’t be avoided, although you can ensure a specialization is only in a single one of your translation units using extern templates.