4 ms·
"Precompiled headers are/were are thing, but they're very brittle." In compilers other than Visual Studio, yes (or so I'm mostly told - I don't have all that m
by roel_v 8y ago
"Precompiled headers are/were are thing, but they're very brittle."
In compilers other than Visual Studio, yes (or so I'm mostly told - I don't have all that much experience with them), but msvc has had them since at least VS6 (late 1990's) when I first started using them, and they work very well and have saved me many, many hours since then. Maybe once or twice I had to delete the pch file in all that time, and that was most likely more of a issue of the GUI mangling the saved internal state than the actual compiler.
I've heard pushback against precompiled headers from Unix land for 2 decades, I'm not really sure where it comes from. I have the impression it's mostly cognitive dissonance - 'msvc has it and gcc doesn't, therefore it must be bad because gcc is 'better' than msvc'. It's similar to #pragma once - in use, it's objectively better in every possible way than include guards are, and gcc fanboys still dismissed it back when gcc didn't have them.
- jcelerier 8y agoGCC had PCH for years though. Every semi-large project I do with GCC / Clang gets the PCH treatment, in particular because it's so simple with CMake.
- gpderetta 8y agoFWIW, gcc has had pragma once for ages. On the other hand recently we had issues with MSVC not recognizing that an header and its simlink were the same. GCC and clang had no problems. There is a reason pragma once is not standardized. Defining when to include lines refer to the same file is extremely hard.