4 ms·
How do you guys deal with the long compilation times? For me, I wouldn't mind C++...if it only compiled faster. Even just two or three C++ files take ~5 seconds
by Meai 15y ago
How do you guys deal with the long compilation times? For me, I wouldn't mind C++...if it only compiled faster. Even just two or three C++ files take ~5 seconds to compile on my machine. Is this not an unacceptable amount of time for you, or do you have tools to make this go below the 3 second threshold? In my mind, this is a serious problem that is keeping me from using C++ more. I try to do as much as possible in C for now.
- octopus 15y agoIt really depends on what compiler you use, in my experience g++ coupled with make is as fast as gcc for compilation. clang++ is even faster. Visual Studio 2010 has a decent compilation speed if you use a Dos prompt.
- roel_v 15y ago- For simple 'syntax checking' compiles, compile only the module ('.cpp file') you're working in. This requires a proper IDE or at least some editor support - for VS it's ctrl-f7. - For 'whole-project' compiles, limit the amount of them to the absolute minimum. Use unit tests to test fundamental functionality rather than running the whole program. - Use a compiler that supports precompiled headers, understand how it works and use it as it's designed. - Pay attention to your #include graph. Only include headers where they're used (i.e., in the .cpp file and not in the header where it's possible), use Cheshire cat where possible, and put as much into the precompiled header as possible. Doing all of these things make C++ compilation bearable, but still it's a nice change when I write code in C# or 'scripting' languages and compilation times disappears. It's one of the more annoying aspects of C++, but despite it and a bunch of other nitpicks, it's still my favorite language.
- copper 15y agoAbout the only thing I'd add to roel_v's excellent sugegstions (to which I cannot reply) is the use of ccache, distcc, and if you can use it, the gold linker. For larger projects, they make compile times bearable. In fact, I usually complain about time spent in linking, rather than compiling.
- marshray 15y agoI took a measurement of the number of non-comment non-blank lines of code for each std c++ header file. I'm now experimenting with writing replacements and wrappers for the classes that require the larger ones. My theory is that I can get by just fine with the 80% of the features that I really need, and end up with 20% of the code. https://github.com/marshray/qak/tree/ https://github.com/marshray/qak/tree/ For example, my simple implementation of min and max<T>(a, b) amount to just a few lines of code. But using them instead of std::min/max means you don't have to #include <algorithm> ... a savings of 39274 LoC!
- malkia 15y agoWe use IncrediBuild.