Under what conditions must cpp code be compiled and linked into the exe
<p>I am using MSVC++ with visual studio 2012, to build basic unmanaged c++ x86/x64 Windows and Console subsystem programs. (exception handling turned off)</p>

<p>I have a rather large project and when curious about the final exe size I decided to see how big it would be if I changed my main() function to just do nothing (so not calling or referencing any of the other code.  I noticed that the exe size was still a lot bigger than when I went and removed all the cpp files from the project.</p>

<p>So I was wondering what types of C++ code would cause code to be linked in even if the main function does nothing.  One example would be having a global variable in one of your cpp files of type A, where A was a class/struct.  In this case I would assume that A's constructor and destructor would have to be included, as well as the constructors and destructor's of the types of all of A's members. </p>

<p>In visual studio I have all optimizations turned on including the linker ones to eliminate functions/data that is never referenced, and comdat folding. and the cpp code generation to enable comdats/function level linking.</p>

<p><strong>Update:</strong>
I am not using any C++11 or above functionality. Though I'm not sure if my build environment is set up to build for c++11 or above, or if this would make any difference.</p>