4 ms·
> Program files will include rtweekend.h first, so all other header files (where the bulk of our code will reside) can implicitly assume that rtweekend.h has al
by kookamamie 2y ago
> Program files will include rtweekend.h first, so all other header files (where the bulk of our code will reside) can implicitly assume that rtweekend.h has already been included.
Not a great practice. Header files shouldn't assume anything from previous inclusions of other headers.
Sure, this works as a weekend hack, but it would be nice if book (article) would promote good conventions.
- veltas 2y agoThis is a normal practice for applications, and allows you to pre-compile that header for performance. I don't think it's a bad enough practice to warrant complaining, but it's good for people to know the advantages or disadvantages.
- kookamamie 2y agoSee this: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rs-contained https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines... Technically, headers are just copy-paste, obviously. However, there's value to keeping them as standalone as possible.
- on_the_train 2y agoHeaders should still be self contained, although precompiled headers are used. Those things are mostly orthogonal