Boost logo

Boost :

Subject: Re: [boost] Proposal for #pragma once support
From: Sid Sacek (ssacek_at_[hidden])
Date: 2009-06-09 13:49:09

I brought this topic up a couple of months ago, and I got the "Boost
Cold Shoulder".

You see, I believe the head-honchos here are GCC aficionados and don't
care much about Bill Gate's compilers.

I hope you do better than I did.

-Sid Sacek

-----Original Message-----
From: boost-bounces_at_[hidden]
[mailto:boost-bounces_at_[hidden]] On Behalf Of Zachary Turner
Sent: Tuesday, June 09, 2009 12:00 PM
To: boost_at_[hidden]
Subject: [boost] Proposal for #pragma once support

I would like to propose conditional support for #pragma once be added to
header files in boost. This would involve, at the beginning of every
file, a preprocessor check to determine whether or not the particular
compiler is on a whitelist of known compilers to optimized #pragma once.
so, #pragma once is used. so, something like this:

#pragma once

the rest of the header file, including the original #include guard,
could be
as normal. to demonstrate the motivation for this, consider the sample
this page: At
bottom there is a zip file with a visual studio solution that contains 3
different projects. Each project contains 200 header file, each of
includes all of the other 199 header files. There is a single cpp file
a main function which includes all 200 header files. All 3 projects use
internal #include guards. In addition:

Project 'RedundantGuard' - Uses external include guards (wrapping the
invocation of #include itself inside the appropriate guard) as discussed
the book Large Scale C++ Software Design
Project 'PragmaOnce' - Uses #pragma once
Project 'Nothing' - Uses nothing additional other than the internal

Here are the build timings on my machine (Visual Studio 2008 Service
Pack 2)

RedundantGuard - 1 second compile + link time
PragmaOnce - 1 second compile + link time
Nothing - 15 seconds compile + link time

In addition I have tested this in the code base of a commercial product
I am
working on (~40,000 lines of code). It consists of about 6 different
projects, some of which have dependencies between each other and some
don't, so that parallel compilation can happen in some instances

RedundantGuard - Not Tested
PragmaOnce - 1 minute, 25 seconds compile + link time
Nothing - 2 minutes, 1 second compile + link time

So, I believe that boost compile times can benefit significantly from


Boost list run by bdawes at, gregod at, cpdaniel at, john at