Boost C++ Libraries: Ticket #1532: #pragma once https://svn.boost.org/trac10/ticket/1532 <p> The most of modern compilers do support #pragma once feature. This can reduce significantly the compilation time. Boost should use this too. </p> <p> Proposal: In boost/config.hpp define the BOOST_ONCE macro: (Of course this should be defined in the right compiler configuration header file) </p> <pre class="wiki">!#cpp // VC &gt;4.0 // GCC &gt;=4.30 // ICC &gt;10 #if (defined(_MSC_VER) &amp;&amp; _MSC_VER &gt; 1000) || \ (defined(__GNUC__) &amp;&amp; ((__GNUC__ == 4 &amp;&amp; __GNUC_MINOR__ &gt;= 30) || (__GNUC__ &gt; 4))) || \ (defined(__ICC) &amp;&amp; __ICC &gt; 1000) # define BOOST_ONCE once #else # define BOOST_ONCE message("") #endif </pre><p> Using in other files: boost/xxx/yyy.hpp </p> <pre class="wiki">!#cpp #ifndef BOOST_XXX_YYY_INCLUDED #define BOOST_XXX_YYY_INCLUDED #include &lt;boost/config.hpp&gt; #pragma BOOST_ONCE #endif // BOOST_XXX_YYY_INCLUDED </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1532 Trac 1.4.3 niels_dekker Tue, 22 Jan 2008 16:11:48 GMT <link>https://svn.boost.org/trac10/ticket/1532#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1532#comment:1</guid> <description> <p> Thanks for your ticket. But the use of <em>#pragma once</em> appears rather controversial. You may want to check out the discussion on comp.std.c++, in December 2007: <a class="ext-link" href="http://groups.google.com/group/comp.std.c++/browse_thread/thread/c527240043c8df92#52ed613066ac6d59"><span class="icon">​</span>#pragma once in ISO standard yet?</a> (73 postings!) </p> <p> GCC 4 has already declared <em>#pragma once</em> as being obsolete: <a class="ext-link" href="http://gcc.gnu.org/onlinedocs/gcc-4.0.0/cpp/Obsolete-once_002donly-headers.html#Obsolete-once_002donly-headers"><span class="icon">​</span>Obsolete once-only headers</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>NN</dc:creator> <pubDate>Fri, 25 Jan 2008 08:23:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1532#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1532#comment:2</guid> <description> <p> Defining the macro is a good solution for this program, because if #pragma once will be declared as unsupported in GCC 5.x it may do nothing. </p> <p> Anyway #pragma once does decrease the compilation time, so there is no reason not to define the macro and use it. Because it can be simply disabled in a simple and a standard way. </p> <p> Thanx. </p> </description> <category>Ticket</category> </item> <item> <author>Shunsuke Sogame <pstade.mb@…></author> <pubDate>Thu, 14 Feb 2008 16:03:11 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1532#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1532#comment:3</guid> <description> <p> Replying to <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1532" title="#1532: Feature Requests: #pragma once (closed: wontfix)">NN</a>: </p> <blockquote class="citation"> <p> The most of modern compilers do support #pragma once feature. This can reduce significantly the compilation time. </p> </blockquote> <p> Seems cool macro. Which compiler would compile faster? </p> <p> Regards, </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 06 Jun 2009 15:15:46 GMT</pubDate> <title>component changed; owner set https://svn.boost.org/trac10/ticket/1532#comment:4 https://svn.boost.org/trac10/ticket/1532#comment:4 <ul> <li><strong>owner</strong> set to <span class="trac-author">John Maddock</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">config</span> </li> </ul> Ticket John Maddock Sat, 06 Jun 2009 16:58:49 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/1532#comment:5 https://svn.boost.org/trac10/ticket/1532#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> I thought we did some tests and decided it wasn't worth the effort? Compilers are mostly smart enough now not to need this hint. </p> <p> In any case the proposed solution won't work: #pragma message isn't supported by anything except MSVC I believe, so every other compiler would emit a warning about an unknown pragma :-( </p> <p> We could define a BOOST_HAS_PRAGMA_ONCE, but this would basically be synonymous with _MSC_VER I believe and therefore superfluous, especially now the only other case - GCC - has deprecated this. </p> <p> Closing down for now, please reopen if a better solution presents itself and/or if you have convincing use cases (with data!) :-) </p> <p> John. </p> Ticket