From 75d100a4ac0f19861f0edda28c811a238feda612 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Sat, 15 Jun 2013 16:40:46 +0000 Subject: [PATCH] Added BOOST_HAS_PRAGMA_ONCE for compilers that support it. The macro was already defined for DMC, but not for other compilers and was not documented. [SVN r84796] --- doc/macro_reference.qbk | 6 ++++++ include/boost/config/compiler/borland.hpp | 4 ---- include/boost/config/compiler/clang.hpp | 2 ++ include/boost/config/compiler/codegear.hpp | 6 ++++++ include/boost/config/compiler/common_edg.hpp | 5 +++++ include/boost/config/compiler/gcc.hpp | 5 +++++ include/boost/config/compiler/visualc.hpp | 4 ++++ 7 files changed, 28 insertions(+), 4 deletions(-) diff --git a/doc/macro_reference.qbk b/doc/macro_reference.qbk index d52682d0..d334d7f0 100644 --- a/doc/macro_reference.qbk +++ b/doc/macro_reference.qbk @@ -397,6 +397,12 @@ See [@../../../../boost/operators.hpp ``] for example. The standard library has a partially conforming `std::allocator` class, but without any of the member templates. ]] +[[`BOOST_HAS_PRAGMA_ONCE`][Compiler][ +The compiler recognizes the `#pragma once` directive which tells that the +containing header should be included only once while preprocessing the +current translation unit. The pragma may improve compile times of large projects +with some compilers. +]] [[`BOOST_HAS_PTHREAD_DELAY_NP`][Platform][ The platform has the POSIX API `pthread_delay_np`. ]] diff --git a/include/boost/config/compiler/borland.hpp b/include/boost/config/compiler/borland.hpp index bf0aad48..745c240c 100644 --- a/include/boost/config/compiler/borland.hpp +++ b/include/boost/config/compiler/borland.hpp @@ -283,7 +283,3 @@ #define BOOST_NO_COMPLETE_VALUE_INITIALIZATION #define BOOST_COMPILER "Borland C++ version " BOOST_STRINGIZE(__BORLANDC__) - - - - diff --git a/include/boost/config/compiler/clang.hpp b/include/boost/config/compiler/clang.hpp index 15e01c68..31ca4f18 100644 --- a/include/boost/config/compiler/clang.hpp +++ b/include/boost/config/compiler/clang.hpp @@ -8,6 +8,8 @@ // Clang compiler setup. +#define BOOST_HAS_PRAGMA_ONCE + #if !__has_feature(cxx_exceptions) && !defined(BOOST_NO_EXCEPTIONS) # define BOOST_NO_EXCEPTIONS #endif diff --git a/include/boost/config/compiler/codegear.hpp b/include/boost/config/compiler/codegear.hpp index 199acaf1..c60ce7da 100644 --- a/include/boost/config/compiler/codegear.hpp +++ b/include/boost/config/compiler/codegear.hpp @@ -72,6 +72,12 @@ # endif #endif + +// Reportedly, #pragma once is supported since C++ Builder 2010 +#if (__CODEGEARC__ >= 0x620) +# define BOOST_HAS_PRAGMA_ONCE +#endif + // // C++0x macros: // diff --git a/include/boost/config/compiler/common_edg.hpp b/include/boost/config/compiler/common_edg.hpp index 80610adc..8bdf7706 100644 --- a/include/boost/config/compiler/common_edg.hpp +++ b/include/boost/config/compiler/common_edg.hpp @@ -54,6 +54,11 @@ # define BOOST_NO_LONG_LONG # endif +// Not sure what version was the first to support #pragma once, but +// different EDG-based compilers (e.g. Intel) supported it for ages. +// Add a proper version check if it causes problems. +#define BOOST_HAS_PRAGMA_ONCE + // // C++0x features // diff --git a/include/boost/config/compiler/gcc.hpp b/include/boost/config/compiler/gcc.hpp index e333308a..4ce54d7c 100644 --- a/include/boost/config/compiler/gcc.hpp +++ b/include/boost/config/compiler/gcc.hpp @@ -80,6 +80,11 @@ # endif #endif +// GCC prior to 3.4 had #pragma once too but it didn't work well with filesystem links +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +#define BOOST_HAS_PRAGMA_ONCE +#endif + #if __GNUC__ < 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ < 4 ) // Previous versions of GCC did not completely implement value-initialization: // GCC Bug 30111, "Value-initialization of POD base class doesn't initialize diff --git a/include/boost/config/compiler/visualc.hpp b/include/boost/config/compiler/visualc.hpp index 5de0ed74..c4aa8287 100644 --- a/include/boost/config/compiler/visualc.hpp +++ b/include/boost/config/compiler/visualc.hpp @@ -34,6 +34,10 @@ // Attempt to suppress VC6 warnings about the length of decorated names (obsolete): #pragma warning( disable : 4503 ) // warning: decorated name length exceeded +#if _MSC_VER >= 1020 +# define BOOST_HAS_PRAGMA_ONCE +#endif + // // versions check: // we don't support Visual C++ prior to version 6: