Possible Duplicate:
Why does C++ compilation take so long?
Coming from C# background, I can’t help but notice that the speed of compilation for C++ and C# code differs a lot– C# is very fast to compile, but C++ is comparatively slow– very slow, in fact.
Why is this so?
Two big reasons:
C++ has to go and
#includeand parse all the header files (which means reading text files and interpreting them — including templates — and then expanding them right into your code) whereas C# uses pre-compiled information in the assembly DLLs.The potential C++ optimizations are way more far-reaching than the C# optimizations; they easily blow C# out of the water. The C# compiler never inlines a function call (that’s the Just-In-Time compiler’s job to do in the CLR), but C++ compilers frequently do that, and much more. The C++ compiler also has to do the JIT’s compiler for the entire program at compile time (and then some!), so it’s definitely slower.
I’d say that the biggest culprit is optimizations — try turning off all optimizations in your compiler, and noticing the speedup.