3 ms·
one issue in c/c++ is that each compilation unit (i.e. cpp file) includes tons of headers which in turn include tons more headers. so it's like an O(n^2) kind
by madethissoicou 4y ago
one issue in c/c++ is that each compilation unit (i.e. cpp file) includes tons of headers which in turn include tons more headers. so it's like an O(n^2) kind of growth where n is source size. obvs you can do better if you're careful about dependencies
- yetihehe 4y agoCompound that with inability to cache those headers between different compilation units because each time you include a header, it can behave differently thanks to preprocessor definitions, but you can't really make dependency of those definitions because even changing order of header inclusion can make difference to those definitions.
- canucker2016 4y ago...which is why sane, large projects use precompiled headers (PCH). C (and later C++) compilers have used precompiled headers since at least the late 80s. PCH speeds up compilation and roots out (hopefully, the few) cases where precompiled headers fail. But C/C++ wasn't designed for a world where tens/hundreds of programmers build an app measured in the tens/hundreds of megabytes.
- CyberDildonics 4y agoThere is no reason to lump these together. C will compile practically instantly if there are no optimizations on while C++ will still take a non trivial chunk of time. SQLite is 6 MB of pure C and it compiles in a fraction of a second with the msvc compiler.