|
Boost : |
Subject: Re: [boost] [preprocessor] include speed question
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2012-05-10 13:11:23
On 10.05.2012, at 18:30, lcaminiti wrote:
> This way is more module in that each single file includes all the headers
> that it needs. But, does that slow down compilation? Would it be faster to
> just #include <boost/preprocessor.hpp> just once into a front-end header
> that then includes all my single header files? (Maybe with modern compilers
> and file-systems this makes no difference?)
GCC and Clang, and probably most compilers, recognize include guards for what they are and won't even look at the file for subsequent inclusion directives. So redundant includes there should take basically no time.
MSVC doesn't implement this optimization AFAIK - there you have to use the #pragma once directive to achieve this effect. Otherwise the compiler will open and read the file again, even if it is just to scan past the entire content.
Sebastian
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk