Comment by jsheard

17 days ago

I agree it shouldn't really matter if there's no C++ features in play, but I suppose third party headers could bite you if they use #ifdef __cplusplus to guard optional C++ extensions on top of their basic C interface. In that case the compiler could be dealing with dramatically more complex code when you build in C++ mode.

Maybe it is similar for the same compiler (but one should check, I suspect C could still be faster), but then there are much more C compilers. For example, TCC is a lot faster than GCC.

  • tcc is 8x faster, twice as fast isn't doing it justice.

    As for the header thing, that'd could potentially be true if the compile time was something like 450ms -> 220ms, but why bother saying it when you're only saving a few hundred milliseconds

    • Going from 220 to 450 ms would be a disaster in my project. It has many thousands of files. Recompilation of almost everything happens from time to time.

      If those made-up numbers were true, they would be very significant and an argument in favor of keeping the code in C

      1 reply →

  • The question is the performance optimisations on top.

    1990's compilers were also super fast, they only did optimisation for size, speed, constant propagation, and little else.

    Zero code motion, loop unroling, code elision, heap via stack replacement, inlining,...