4 ms·
I recently had to switch a project to -std=c++11 because a header I include now uses C++11 files. This change alone made compilation at least twice if not three
by cm3 10y ago
I recently had to switch a project to -std=c++11 because a header I include now uses C++11 files. This change alone made compilation at least twice if not three times as slow. The new safety and convenience features are nice but compile times seem to be out of focus and getting slower and slower every year. I don't know how I feel with g++ 6.1 defaulting to -std=gnu++14.
- netheril96 10y agoHow do you know that it is c++11 switch that dramatically increased your compile time, instead of the header file and the headers it includes? Two conditions are changed, and you feel confident that one of them is responsible for the outcome. Why?
- cm3 10y agoBecause it's a C++11 header that doesn't exist in C++98. And I cannot compile that version without switching to C++11 mode. Edit: there appears to be some confusion here. I don't include the C++11 header myself. I include a public API header of another project which now happens to include a C++11 header in their public include file. Unless I want to stay on the old version of that API and accept the risks, I don't have a choice whether I compile my consumer module in C++11 mode or not. And it's a major fault of the C++ language that there are no modules and therefore this include file overhead and mess. They appear to be working towards a module system, thankfully.
- netheril96 10y ago> Because it's a C++11 header that doesn't exist in C++98. That is supposed to be a fault of C++11?
- cm3 10y agoI don't understand your argument. An upstream project I use put a C++11 header in their public API's header. Now, I also have to build in C++11 language mode. If you're saying it's not the language standard's fault that CXX is slower, sure, but how or why should I differentiate between ISO C++ and g++/clang++ with libstd++/libc++?
- vmarsy 10y agoI think what the GP was saying is: Ignore the new feature you're using from that upstream project for a minute. Did you try compiling your project with -std=c++11 before doing any other change? That is the only way you'd clearly see the difference of switching to C++11 in your project. Maybe it won't add any compilation time, it could even be faster... And then you add the new feature and your compile time goes crazy, that's unfortunate indeed, but that's the price of not being penalized at run time with the [cool new C++11 feature the upstream project is using], you have to endure a longer compile time. But you can't blame C++11 for it, without it that feature wouldn't even exist!
- cm3 10y agoThis makes more sense, but why is it not C++11's fault if compiler writers have a hard time keeping the compile time overhead in reasonable bounds? Compiler writers actually do not enable some optimization passes or cap some passes at a certain search level because they know the algorithmic complexity would be unacceptable for most users, although the performance benefit is clear. The planned C++ module system will most likely solve a large set of the pain points.
- deleted 10y ago[deleted]
- restalis 10y agoThe right answer should have been "because that was the bench-marked time result for the same code-base compiled in both modes" (before including the new header).