From b7249be32fe7a8c5f08b5f01f429b43b8720d6f4 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 22 Jan 2002 13:38:52 +0000 Subject: [PATCH 01/37] Smart pointer enhancements, initial commit [SVN r12439] --- include/boost/assert.hpp | 52 +++++++++++++++++++++++++++ include/boost/current_function.hpp | 56 ++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 include/boost/assert.hpp create mode 100644 include/boost/current_function.hpp diff --git a/include/boost/assert.hpp b/include/boost/assert.hpp new file mode 100644 index 0000000..3a501dc --- /dev/null +++ b/include/boost/assert.hpp @@ -0,0 +1,52 @@ +#ifndef BOOST_ASSERT_HPP_INCLUDED +#define BOOST_ASSERT_HPP_INCLUDED + +#if _MSC_VER >= 1020 +#pragma once +#endif + +// +// boost/assert.hpp +// +// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// + +// +// When BOOST_DEBUG is not defined, it defaults to 0 (off) +// for backward compatibility with programs that do not +// define a boost_error handler +// +// After a reasonable transition period, the default can be +// changed to something more appropriate. +// + +#ifndef BOOST_DEBUG +#define BOOST_DEBUG 0 +#endif + +bool boost_error(char const * expr, char const * func, char const * file, long line); + +#if BOOST_DEBUG + +#include +#include + +#ifndef BOOST_ASSERT + +# define BOOST_ASSERT(expr) ((expr) || !boost_error(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__) || (assert(expr), true)) + +#endif // #ifndef BOOST_ASSERT + +#else // #if BOOST_DEBUG + +#undef BOOST_ASSERT +#define BOOST_ASSERT(expr) ((void)0) + +#endif // #ifdef BOOST_DEBUG + +#endif // #ifndef BOOST_ASSERT_HPP_INCLUDED diff --git a/include/boost/current_function.hpp b/include/boost/current_function.hpp new file mode 100644 index 0000000..e44e26b --- /dev/null +++ b/include/boost/current_function.hpp @@ -0,0 +1,56 @@ +#ifndef BOOST_CURRENT_FUNCTION_HPP_INCLUDED +#define BOOST_CURRENT_FUNCTION_HPP_INCLUDED + +#if _MSC_VER >= 1020 +#pragma once +#endif + +// +// boost/current_function.hpp - BOOST_CURRENT_FUNCTION +// +// Copyright (c) 2002 Peter Dimov and Multi Media Ltd. +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// + +namespace boost +{ + +namespace detail +{ + +void current_function_helper() +{ + +#if defined(__GNUC__) + +# define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__ + +#elif defined(__FUNCSIG__) + +# define BOOST_CURRENT_FUNCTION __FUNCSIG__ + +#elif defined(__BORLANDC__) + +# define BOOST_CURRENT_FUNCTION __FUNC__ + +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) + +# define BOOST_CURRENT_FUNCTION __func__ + +#else + +# define BOOST_CURRENT_FUNCTION "(unknown)" + +#endif + +} + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_CURRENT_FUNCTION_HPP_INCLUDED From b7f1ae24726c09433f50d605d599ae8f80dc8614 Mon Sep 17 00:00:00 2001 From: Darin Adler Date: Tue, 22 Jan 2002 18:28:33 +0000 Subject: [PATCH 02/37] Tweak comments. Include and only when needed. [SVN r12446] --- include/boost/assert.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/boost/assert.hpp b/include/boost/assert.hpp index 3a501dc..645404d 100644 --- a/include/boost/assert.hpp +++ b/include/boost/assert.hpp @@ -18,26 +18,26 @@ // // When BOOST_DEBUG is not defined, it defaults to 0 (off) -// for backward compatibility with programs that do not -// define a boost_error handler +// for compatibility with programs that do not expect asserts +// in the smart pointer class templates. // -// After a reasonable transition period, the default can be -// changed to something more appropriate. +// This default may be changed after an initial transition period. // #ifndef BOOST_DEBUG #define BOOST_DEBUG 0 #endif -bool boost_error(char const * expr, char const * func, char const * file, long line); - #if BOOST_DEBUG -#include #include #ifndef BOOST_ASSERT +#include + +bool boost_error(char const * expr, char const * func, char const * file, long line); + # define BOOST_ASSERT(expr) ((expr) || !boost_error(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__) || (assert(expr), true)) #endif // #ifndef BOOST_ASSERT @@ -47,6 +47,6 @@ bool boost_error(char const * expr, char const * func, char const * file, long l #undef BOOST_ASSERT #define BOOST_ASSERT(expr) ((void)0) -#endif // #ifdef BOOST_DEBUG +#endif // #if BOOST_DEBUG #endif // #ifndef BOOST_ASSERT_HPP_INCLUDED From 4fe8dd675bf49ca444d5bab2f7433cfce1e91db1 Mon Sep 17 00:00:00 2001 From: Darin Adler Date: Thu, 24 Jan 2002 19:15:30 +0000 Subject: [PATCH 03/37] Mark inline to avoid warning with "require prototypes" on. [SVN r12490] --- include/boost/current_function.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/current_function.hpp b/include/boost/current_function.hpp index e44e26b..6d52404 100644 --- a/include/boost/current_function.hpp +++ b/include/boost/current_function.hpp @@ -22,7 +22,7 @@ namespace boost namespace detail { -void current_function_helper() +inline void current_function_helper() { #if defined(__GNUC__) From 2f4e18997ebe5a5ca0954ca95a686b2088b8df10 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 25 Jan 2002 13:54:30 +0000 Subject: [PATCH 04/37] Added tests for the new smart pointers. [SVN r12500] --- assert_test.cpp | 33 +++++++++++++++++++++++++++++++++ current_function_test.cpp | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 assert_test.cpp create mode 100644 current_function_test.cpp diff --git a/assert_test.cpp b/assert_test.cpp new file mode 100644 index 0000000..5813e25 --- /dev/null +++ b/assert_test.cpp @@ -0,0 +1,33 @@ +#if defined(_MSC_VER) && !defined(__ICL) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +// +// assert_test.cpp - a test for boost/assert.hpp +// +// Copyright (c) 2002 Peter Dimov and Multi Media Ltd. +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// + +#define BOOST_DEBUG 1 + +#include +#include + +bool boost_error(char const * expr, char const * func, char const * file, long line) +{ + std::printf("%s(%ld): Assertion '%s' failed in function '%s'\n", file, line, expr, func); + return true; // fail w/ standard assert() +} + +int main() +{ + BOOST_ASSERT(0 == 1); +} diff --git a/current_function_test.cpp b/current_function_test.cpp new file mode 100644 index 0000000..620a45e --- /dev/null +++ b/current_function_test.cpp @@ -0,0 +1,32 @@ +#if defined(_MSC_VER) && !defined(__ICL) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +// +// current_function_test.cpp - a test for boost/current_function.hpp +// +// Copyright (c) 2002 Peter Dimov and Multi Media Ltd. +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// + +#include +#include + +void message(char const * file, long line, char const * func, char const * msg) +{ + std::printf("%s(%ld): %s in function '%s'\n", file, line, msg, func); +} + +#define MESSAGE(msg) message(__FILE__, __LINE__, BOOST_CURRENT_FUNCTION, msg) + +int main() +{ + MESSAGE("assertion failed"); +} From 7701f84cf3c9b50c707749c9fe7db86cf3d32ae6 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 14 Nov 2002 14:41:25 +0000 Subject: [PATCH 05/37] BOOST_CURRENT_FUNCTION documentation added. [SVN r16236] --- current_function.html | 38 ++++++++++++++++++++++++++++++ include/boost/current_function.hpp | 2 ++ 2 files changed, 40 insertions(+) create mode 100644 current_function.html diff --git a/current_function.html b/current_function.html new file mode 100644 index 0000000..158cd4e --- /dev/null +++ b/current_function.html @@ -0,0 +1,38 @@ + + + + Boost: current_function.hpp documentation + + + + + + + + + + + +
+ c++boost.gif (8819 bytes) + +

current_function.hpp

+
 
+

+ The header <boost/current_function.hpp> defines a single + macro, BOOST_CURRENT_FUNCTION, similar to the + C99 macro __func__. +

+

BOOST_CURRENT_FUNCTION expands to a string literal containing + the (fully qualified, if possible) name of the enclosing function. If there is + no enclosing function, the behavior is undefined.

+

Some compilers do not provide a way to obtain the name of the current enclosing + function. On such compilers, the string literal has an unspecified value.

+

+
+ Copyright © 2002 by Peter Dimov. Permission to copy, use, modify, sell and + distribute this document is granted provided this copyright notice appears in + all copies. This document is provided "as is" without express or implied + warranty, and with no claim as to its suitability for any purpose.

+ + diff --git a/include/boost/current_function.hpp b/include/boost/current_function.hpp index 6d52404..0b2841a 100644 --- a/include/boost/current_function.hpp +++ b/include/boost/current_function.hpp @@ -15,6 +15,8 @@ // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // +// http://www.boost.org/libs/utility/current_function.html +// namespace boost { From 36a1add61d10bfbf09fd7996245a07cada8e5efe Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 14 Nov 2002 16:09:29 +0000 Subject: [PATCH 06/37] New BOOST_ASSERT, including documentation. [SVN r16240] --- assert.html | 57 ++++++++++++++++++++++++ assert_test.cpp | 96 +++++++++++++++++++++++++++++++++++----- include/boost/assert.hpp | 46 +++++++------------ 3 files changed, 156 insertions(+), 43 deletions(-) create mode 100644 assert.html diff --git a/assert.html b/assert.html new file mode 100644 index 0000000..d34ce36 --- /dev/null +++ b/assert.html @@ -0,0 +1,57 @@ + + + + Boost: assert.hpp documentation + + + + + + + + + + + +
+ c++boost.gif (8819 bytes) + +

assert.hpp

+
 
+

+ The header <boost/assert.hpp> defines the macro BOOST_ASSERT, + which is similar to the standard assert macro defined in <cassert>. + The macro is intended to be used in Boost libraries. +

+

By default, BOOST_ASSERT(expr) is equivalent to assert(expr).

+

When the macro BOOST_DISABLE_ASSERTS is defined when <boost/assert.hpp> + is included, BOOST_ASSERT(expr) is defined as ((void)0). This + allows users to selectively disable BOOST_ASSERT without + affecting the definition of the standard assert.

+

When the macro BOOST_ENABLE_ASSERT_HANDLER is defined when <boost/assert.hpp> + is included, BOOST_ASSERT(expr) evaluates expr and, if the + result is false, evaluates the expression

+

::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, + __FILE__, __LINE__)

+

assertion_failed is declared in <boost/assert.hpp> + as

+
+namespace boost
+{
+
+void assertion_failed(char const * expr, char const * function, char const * file, long line);
+
+}
+
+

but it is never defined. The user is expected to supply an appropriate + definition.

+

As is the case with <cassert>, <boost/assert.hpp> + can be included multiple times in a single translation unit. BOOST_ASSERT + will be redefined each time as specified above.

+


+ Copyright © 2002 by Peter Dimov. Permission to copy, use, modify, sell and + distribute this document is granted provided this copyright notice appears in + all copies. This document is provided "as is" without express or implied + warranty, and with no claim as to its suitability for any purpose.

+ + diff --git a/assert_test.cpp b/assert_test.cpp index 5813e25..3a7f892 100644 --- a/assert_test.cpp +++ b/assert_test.cpp @@ -1,10 +1,3 @@ -#if defined(_MSC_VER) && !defined(__ICL) -#pragma warning(disable: 4786) // identifier truncated in debug info -#pragma warning(disable: 4710) // function not inlined -#pragma warning(disable: 4711) // function selected for automatic inline expansion -#pragma warning(disable: 4514) // unreferenced inline removed -#endif - // // assert_test.cpp - a test for boost/assert.hpp // @@ -16,18 +9,97 @@ // warranty, and with no claim as to its suitability for any purpose. // -#define BOOST_DEBUG 1 +#include +#include + +void test_default() +{ + int x = 1; + + BOOST_ASSERT(1); + BOOST_ASSERT(x); + BOOST_ASSERT(x == 1); + BOOST_ASSERT(&x); +} + +#define BOOST_DISABLE_ASSERTS +#include + +void test_disabled() +{ + int x = 1; + + BOOST_ASSERT(1); + BOOST_ASSERT(x); + BOOST_ASSERT(x == 1); + BOOST_ASSERT(&x); + + BOOST_ASSERT(0); + BOOST_ASSERT(!x); + BOOST_ASSERT(x == 0); + + void * p = 0; + + BOOST_ASSERT(p); + + // supress warnings + p = &x; + p = &p; +} + +#undef BOOST_DISABLE_ASSERTS + +#define BOOST_ENABLE_ASSERT_HANDLER #include #include -bool boost_error(char const * expr, char const * func, char const * file, long line) +int handler_invoked = 0; + +void boost::assertion_failed(char const * expr, char const * function, char const * file, long line) { - std::printf("%s(%ld): Assertion '%s' failed in function '%s'\n", file, line, expr, func); - return true; // fail w/ standard assert() + std::printf("Expression: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n", expr, function, file, line); + ++handler_invoked; } +struct X +{ + static void f() + { + BOOST_ASSERT(0); + } +}; + +void test_handler() +{ + int x = 1; + + BOOST_ASSERT(1); + BOOST_ASSERT(x); + BOOST_ASSERT(x == 1); + BOOST_ASSERT(&x); + + BOOST_ASSERT(0); + BOOST_ASSERT(!x); + BOOST_ASSERT(x == 0); + + void * p = 0; + + BOOST_ASSERT(p); + + X::f(); + + BOOST_ASSERT(handler_invoked == 5); + BOOST_TEST(handler_invoked == 5); +} + +#undef BOOST_ENABLE_ASSERT_HANDLER + int main() { - BOOST_ASSERT(0 == 1); + test_default(); + test_disabled(); + test_handler(); + + return boost::report_errors(); } diff --git a/include/boost/assert.hpp b/include/boost/assert.hpp index 645404d..c288a1f 100644 --- a/include/boost/assert.hpp +++ b/include/boost/assert.hpp @@ -1,12 +1,5 @@ -#ifndef BOOST_ASSERT_HPP_INCLUDED -#define BOOST_ASSERT_HPP_INCLUDED - -#if _MSC_VER >= 1020 -#pragma once -#endif - // -// boost/assert.hpp +// boost/assert.hpp - BOOST_ASSERT(expr) // // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. // @@ -15,38 +8,29 @@ // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // - -// -// When BOOST_DEBUG is not defined, it defaults to 0 (off) -// for compatibility with programs that do not expect asserts -// in the smart pointer class templates. -// -// This default may be changed after an initial transition period. +// Note: There are no include guards. This is intentional. // -#ifndef BOOST_DEBUG -#define BOOST_DEBUG 0 -#endif +#undef BOOST_ASSERT -#if BOOST_DEBUG +#if defined(BOOST_DISABLE_ASSERTS) -#include +# define BOOST_ASSERT(expr) ((void)0) -#ifndef BOOST_ASSERT +#elif defined(BOOST_ENABLE_ASSERT_HANDLER) #include -bool boost_error(char const * expr, char const * func, char const * file, long line); +namespace boost +{ -# define BOOST_ASSERT(expr) ((expr) || !boost_error(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__) || (assert(expr), true)) +void assertion_failed(char const * expr, char const * function, char const * file, long line); // user defined -#endif // #ifndef BOOST_ASSERT +} // namespace boost -#else // #if BOOST_DEBUG +#define BOOST_ASSERT(expr) ((expr)? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)) -#undef BOOST_ASSERT -#define BOOST_ASSERT(expr) ((void)0) - -#endif // #if BOOST_DEBUG - -#endif // #ifndef BOOST_ASSERT_HPP_INCLUDED +#else +# include +# define BOOST_ASSERT(expr) assert(expr) +#endif From a1bf7a0e9c271dc7674d1bc9e2653cd19f84d21d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 15 Nov 2002 19:44:18 +0000 Subject: [PATCH 07/37] Metrowerks support (Bertolt Mildner) [SVN r16263] --- include/boost/current_function.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/current_function.hpp b/include/boost/current_function.hpp index 0b2841a..2cfd604 100644 --- a/include/boost/current_function.hpp +++ b/include/boost/current_function.hpp @@ -27,7 +27,7 @@ namespace detail inline void current_function_helper() { -#if defined(__GNUC__) +#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) # define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__ From 87b5ce49e2805940d35f8aaa39b78b044eadbddb Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 28 Nov 2002 13:32:44 +0000 Subject: [PATCH 08/37] Fix: Comeau with bcc32 as backend defines __BORLANDC__ as 1. [SVN r16455] --- include/boost/current_function.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/current_function.hpp b/include/boost/current_function.hpp index 2cfd604..66cb729 100644 --- a/include/boost/current_function.hpp +++ b/include/boost/current_function.hpp @@ -35,7 +35,7 @@ inline void current_function_helper() # define BOOST_CURRENT_FUNCTION __FUNCSIG__ -#elif defined(__BORLANDC__) +#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550) # define BOOST_CURRENT_FUNCTION __FUNC__ From eff02199594aed57bdf7a6a03867ab9f45ed20b0 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Mon, 23 Dec 2002 02:43:12 +0000 Subject: [PATCH 09/37] Add /libs/lib-name to comment [SVN r16685] --- include/boost/assert.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/boost/assert.hpp b/include/boost/assert.hpp index c288a1f..4680408 100644 --- a/include/boost/assert.hpp +++ b/include/boost/assert.hpp @@ -11,6 +11,9 @@ // Note: There are no include guards. This is intentional. // +// See http://www.boost.org/libs/utility for Documentation. + + #undef BOOST_ASSERT #if defined(BOOST_DISABLE_ASSERTS) From 32ec5215ee4b4e8c6acc29873fb329216fc9b79a Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 24 Dec 2002 12:34:42 +0000 Subject: [PATCH 10/37] Doc link updated. [SVN r16699] --- include/boost/assert.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/boost/assert.hpp b/include/boost/assert.hpp index 4680408..754ebb9 100644 --- a/include/boost/assert.hpp +++ b/include/boost/assert.hpp @@ -10,9 +10,8 @@ // // Note: There are no include guards. This is intentional. // - -// See http://www.boost.org/libs/utility for Documentation. - +// See http://www.boost.org/libs/utility/assert.html for documentation. +// #undef BOOST_ASSERT From b01a9470788b2c589c63e3565907939b4a49bcce Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 10 Feb 2003 16:25:41 +0000 Subject: [PATCH 11/37] __func__ is a predefined identifier, not a macro. [SVN r17308] --- current_function.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/current_function.html b/current_function.html index 158cd4e..e1b25d5 100644 --- a/current_function.html +++ b/current_function.html @@ -21,7 +21,7 @@

The header <boost/current_function.hpp> defines a single macro, BOOST_CURRENT_FUNCTION, similar to the - C99 macro __func__. + C99 predefined identifier __func__.

BOOST_CURRENT_FUNCTION expands to a string literal containing the (fully qualified, if possible) name of the enclosing function. If there is From c242f14d91da1ae0d60df97a2ca90e1105947a8f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 23 May 2003 22:30:23 +0000 Subject: [PATCH 12/37] Intel support. [SVN r18520] --- include/boost/current_function.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/boost/current_function.hpp b/include/boost/current_function.hpp index 66cb729..732fb2d 100644 --- a/include/boost/current_function.hpp +++ b/include/boost/current_function.hpp @@ -27,7 +27,7 @@ namespace detail inline void current_function_helper() { -#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) +#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) # define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__ @@ -35,6 +35,10 @@ inline void current_function_helper() # define BOOST_CURRENT_FUNCTION __FUNCSIG__ +#elif defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600) + +# define BOOST_CURRENT_FUNCTION __FUNCTION__ + #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550) # define BOOST_CURRENT_FUNCTION __FUNC__ From d1d4e325167216aa6cceb79d6aef8214fc4b2f77 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 28 May 2003 13:45:58 +0000 Subject: [PATCH 13/37] IBM C++ support added. [SVN r18587] --- include/boost/current_function.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/current_function.hpp b/include/boost/current_function.hpp index 732fb2d..516a394 100644 --- a/include/boost/current_function.hpp +++ b/include/boost/current_function.hpp @@ -35,7 +35,7 @@ inline void current_function_helper() # define BOOST_CURRENT_FUNCTION __FUNCSIG__ -#elif defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600) +#elif (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) || (defined(__IBMCPP__) && (__IBMCPP__ >= 500)) # define BOOST_CURRENT_FUNCTION __FUNCTION__ From a94d04d1dfa21e1b3fa3470ef019e9972089bfa0 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 12 Jun 2003 17:09:24 +0000 Subject: [PATCH 14/37] -Wundef fixes. [SVN r18788] --- include/boost/current_function.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/current_function.hpp b/include/boost/current_function.hpp index 516a394..38aeab2 100644 --- a/include/boost/current_function.hpp +++ b/include/boost/current_function.hpp @@ -1,8 +1,8 @@ #ifndef BOOST_CURRENT_FUNCTION_HPP_INCLUDED #define BOOST_CURRENT_FUNCTION_HPP_INCLUDED -#if _MSC_VER >= 1020 -#pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once #endif // From 4ededfcf76ca2f2782a606b51349c1cd77848bbe Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 28 Nov 2003 15:35:21 +0000 Subject: [PATCH 15/37] _MSC_VER use clarified. [SVN r20992] --- current_function_test.cpp | 4 +++- include/boost/current_function.hpp | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/current_function_test.cpp b/current_function_test.cpp index 620a45e..a724986 100644 --- a/current_function_test.cpp +++ b/current_function_test.cpp @@ -1,4 +1,6 @@ -#if defined(_MSC_VER) && !defined(__ICL) +#include + +#if defined(BOOST_MSVC) #pragma warning(disable: 4786) // identifier truncated in debug info #pragma warning(disable: 4710) // function not inlined #pragma warning(disable: 4711) // function selected for automatic inline expansion diff --git a/include/boost/current_function.hpp b/include/boost/current_function.hpp index 38aeab2..4aea5ef 100644 --- a/include/boost/current_function.hpp +++ b/include/boost/current_function.hpp @@ -1,6 +1,8 @@ #ifndef BOOST_CURRENT_FUNCTION_HPP_INCLUDED #define BOOST_CURRENT_FUNCTION_HPP_INCLUDED +// MS compatible compilers support #pragma once + #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif From 93bb9faf25699bd21664a0fdceba61216376aad6 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 26 Jul 2004 00:32:12 +0000 Subject: [PATCH 16/37] Converted to Boost Software License, Version 1.0 [SVN r24055] --- assert_test.cpp | 7 +++---- current_function_test.cpp | 7 +++---- include/boost/assert.hpp | 7 +++---- include/boost/current_function.hpp | 7 +++---- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/assert_test.cpp b/assert_test.cpp index 3a7f892..24f9761 100644 --- a/assert_test.cpp +++ b/assert_test.cpp @@ -3,10 +3,9 @@ // // Copyright (c) 2002 Peter Dimov and Multi Media Ltd. // -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #include diff --git a/current_function_test.cpp b/current_function_test.cpp index a724986..7510948 100644 --- a/current_function_test.cpp +++ b/current_function_test.cpp @@ -12,10 +12,9 @@ // // Copyright (c) 2002 Peter Dimov and Multi Media Ltd. // -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #include diff --git a/include/boost/assert.hpp b/include/boost/assert.hpp index 754ebb9..3428efb 100644 --- a/include/boost/assert.hpp +++ b/include/boost/assert.hpp @@ -3,10 +3,9 @@ // // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. // -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // Note: There are no include guards. This is intentional. // diff --git a/include/boost/current_function.hpp b/include/boost/current_function.hpp index 4aea5ef..40e3abd 100644 --- a/include/boost/current_function.hpp +++ b/include/boost/current_function.hpp @@ -12,10 +12,9 @@ // // Copyright (c) 2002 Peter Dimov and Multi Media Ltd. // -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // http://www.boost.org/libs/utility/current_function.html // From 6ad5ec4810fe036f99701de5970bf12ed370e939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20M=2E=20L=C3=B3pez=20Mu=C3=B1oz?= Date: Wed, 22 Sep 2004 17:18:06 +0000 Subject: [PATCH 17/37] taken care of BOOST_NO_STDC_NAMESPACE [SVN r25345] --- assert_test.cpp | 7 ++++++- current_function_test.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/assert_test.cpp b/assert_test.cpp index 24f9761..693adc4 100644 --- a/assert_test.cpp +++ b/assert_test.cpp @@ -51,13 +51,18 @@ void test_disabled() #define BOOST_ENABLE_ASSERT_HANDLER #include +#include #include int handler_invoked = 0; void boost::assertion_failed(char const * expr, char const * function, char const * file, long line) { - std::printf("Expression: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n", expr, function, file, line); +#if !defined(BOOST_NO_STDC_NAMESPACE) + using std::printf; +#endif + + printf("Expression: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n", expr, function, file, line); ++handler_invoked; } diff --git a/current_function_test.cpp b/current_function_test.cpp index 7510948..d5651ad 100644 --- a/current_function_test.cpp +++ b/current_function_test.cpp @@ -18,11 +18,16 @@ // #include +#include #include void message(char const * file, long line, char const * func, char const * msg) { - std::printf("%s(%ld): %s in function '%s'\n", file, line, msg, func); +#if !defined(BOOST_NO_STDC_NAMESPACE) + using std::printf; +#endif + + printf("%s(%ld): %s in function '%s'\n", file, line, msg, func); } #define MESSAGE(msg) message(__FILE__, __LINE__, BOOST_CURRENT_FUNCTION, msg) From 60ba31a01833c92355d99cf3cdd813c66b440969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20M=2E=20L=C3=B3pez=20Mu=C3=B1oz?= Date: Fri, 24 Sep 2004 06:17:26 +0000 Subject: [PATCH 18/37] added explicit return to main [SVN r25387] --- current_function_test.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/current_function_test.cpp b/current_function_test.cpp index d5651ad..1343901 100644 --- a/current_function_test.cpp +++ b/current_function_test.cpp @@ -35,4 +35,6 @@ void message(char const * file, long line, char const * func, char const * msg) int main() { MESSAGE("assertion failed"); + + return 0; } From 328658e097a5461f7edb16f3d84e56ff9fbf906e Mon Sep 17 00:00:00 2001 From: Aleksey Gurtovoy Date: Tue, 5 Oct 2004 15:45:52 +0000 Subject: [PATCH 19/37] c++boost.gif -> boost.png replacement [SVN r25573] --- assert.html | 2 +- current_function.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assert.html b/assert.html index d34ce36..617f212 100644 --- a/assert.html +++ b/assert.html @@ -8,7 +8,7 @@
- c++boost.gif (8819 bytes) + boost.png (6897 bytes)

assert.hpp

diff --git a/current_function.html b/current_function.html index e1b25d5..31633f8 100644 --- a/current_function.html +++ b/current_function.html @@ -8,7 +8,7 @@
- c++boost.gif (8819 bytes) + boost.png (6897 bytes)

current_function.hpp

From c5baaca438d7289e21ca159e021a6de03de5b8ca Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Mon, 21 Feb 2005 12:32:20 +0000 Subject: [PATCH 20/37] Add comment explaining use of assert.h [SVN r27473] --- include/boost/assert.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/assert.hpp b/include/boost/assert.hpp index 3428efb..5619f29 100644 --- a/include/boost/assert.hpp +++ b/include/boost/assert.hpp @@ -32,6 +32,6 @@ void assertion_failed(char const * expr, char const * function, char const * fil #define BOOST_ASSERT(expr) ((expr)? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)) #else -# include +# include // .h to support old libraries w/o - effect is the same # define BOOST_ASSERT(expr) assert(expr) #endif From 8d5cc3468bcc08051f8333cc3e5e3c1a33ac5229 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 25 Sep 2005 21:54:19 +0000 Subject: [PATCH 21/37] Made the Boost logo link to the home page [SVN r31112] --- assert.html | 5 ++--- current_function.html | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/assert.html b/assert.html index 617f212..a3dec66 100644 --- a/assert.html +++ b/assert.html @@ -7,10 +7,9 @@ - - diff --git a/current_function.html b/current_function.html index 31633f8..f383e3a 100644 --- a/current_function.html +++ b/current_function.html @@ -7,10 +7,9 @@
- boost.png (6897 bytes) + boost.png (6897 bytes) +

assert.hpp

- - From d43862ab951397fc754da2c6a4a2e2212cb24b87 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 22 Jun 2006 12:47:19 +0000 Subject: [PATCH 22/37] Digital Mars support (Pavel Vozenilek) [SVN r34373] --- include/boost/current_function.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/boost/current_function.hpp b/include/boost/current_function.hpp index 40e3abd..aa5756e 100644 --- a/include/boost/current_function.hpp +++ b/include/boost/current_function.hpp @@ -32,6 +32,10 @@ inline void current_function_helper() # define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__ +#elif defined(__DMC__) && (__DMC__ >= 0x810) + +# define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__ + #elif defined(__FUNCSIG__) # define BOOST_CURRENT_FUNCTION __FUNCSIG__ From c2521c2558c0bedf0520ee60fdba1816047d259f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 9 Nov 2006 20:34:33 +0000 Subject: [PATCH 23/37] License/copyright edits [SVN r35958] --- assert.html | 7 +++---- current_function.html | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/assert.html b/assert.html index a3dec66..4381ae1 100644 --- a/assert.html +++ b/assert.html @@ -48,9 +48,8 @@ void assertion_failed(char const * expr, char const * function, char const * fil can be included multiple times in a single translation unit. BOOST_ASSERT will be redefined each time as specified above.


- Copyright © 2002 by Peter Dimov. Permission to copy, use, modify, sell and - distribute this document is granted provided this copyright notice appears in - all copies. This document is provided "as is" without express or implied - warranty, and with no claim as to its suitability for any purpose.

+ Copyright © 2002 by Peter Dimov. Distributed under the Boost Software License, Version + 1.0. See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt.

diff --git a/current_function.html b/current_function.html index f383e3a..373eb22 100644 --- a/current_function.html +++ b/current_function.html @@ -29,9 +29,8 @@ function. On such compilers, the string literal has an unspecified value.


- Copyright © 2002 by Peter Dimov. Permission to copy, use, modify, sell and - distribute this document is granted provided this copyright notice appears in - all copies. This document is provided "as is" without express or implied - warranty, and with no claim as to its suitability for any purpose.

+ Copyright © 2002 by Peter Dimov. Distributed under the Boost Software License, Version + 1.0. See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt.

From 5392fc5a1c0d161e9d37365e6a4c56fe5a024312 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 3 Nov 2007 20:55:22 +0000 Subject: [PATCH 24/37] BOOST_VERIFY added. [SVN r40728] --- assert.html | 10 +++- include/boost/assert.hpp | 13 ++++ verify_test.cpp | 126 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 146 insertions(+), 3 deletions(-) create mode 100644 verify_test.cpp diff --git a/assert.html b/assert.html index 4381ae1..e65e791 100644 --- a/assert.html +++ b/assert.html @@ -47,9 +47,13 @@ void assertion_failed(char const * expr, char const * function, char const * fil

As is the case with <cassert>, <boost/assert.hpp> can be included multiple times in a single translation unit. BOOST_ASSERT will be redefined each time as specified above.

+

<boost/assert.hpp> also defines the macro BOOST_VERIFY. + It has exactly the same behavior as BOOST_ASSERT, except + that the expression that is passed to BOOST_VERIFY is always + evaluated.


- Copyright © 2002 by Peter Dimov. Distributed under the Boost Software License, Version - 1.0. See accompanying file LICENSE_1_0.txt or - copy at http://www.boost.org/LICENSE_1_0.txt.

+ Copyright © 2002, 2007 by Peter Dimov. Distributed under the Boost + Software License, Version 1.0. See accompanying file + LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.

diff --git a/include/boost/assert.hpp b/include/boost/assert.hpp index 5619f29..c227f17 100644 --- a/include/boost/assert.hpp +++ b/include/boost/assert.hpp @@ -2,6 +2,7 @@ // boost/assert.hpp - BOOST_ASSERT(expr) // // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. +// Copyright (c) 2007 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -35,3 +36,15 @@ void assertion_failed(char const * expr, char const * function, char const * fil # include // .h to support old libraries w/o - effect is the same # define BOOST_ASSERT(expr) assert(expr) #endif + +#undef BOOST_VERIFY + +#if defined(BOOST_DISABLE_ASSERTS) || ( !defined(BOOST_ENABLE_ASSERT_HANDLER) && defined(NDEBUG) ) + +# define BOOST_VERIFY(expr) ((void)(expr)) + +#else + +# define BOOST_VERIFY(expr) BOOST_ASSERT(expr) + +#endif diff --git a/verify_test.cpp b/verify_test.cpp new file mode 100644 index 0000000..3481636 --- /dev/null +++ b/verify_test.cpp @@ -0,0 +1,126 @@ +// +// verify_test.cpp - a test for BOOST_VERIFY +// +// Copyright (c) 2002 Peter Dimov and Multi Media Ltd. +// Copyright (c) 2007 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#include + +#include + +int f( int & x ) +{ + return ++x; +} + +void test_default() +{ + int x = 1; + + BOOST_VERIFY( 1 ); + BOOST_VERIFY( x == 1 ); + BOOST_VERIFY( ++x ); + BOOST_VERIFY( f(x) ); + BOOST_VERIFY( &x ); + + BOOST_TEST( x == 3 ); +} + +#define BOOST_DISABLE_ASSERTS +#include + +void test_disabled() +{ + int x = 1; + + BOOST_VERIFY( 1 ); + BOOST_VERIFY( x == 1 ); + BOOST_VERIFY( ++x ); + BOOST_VERIFY( f(x) ); + BOOST_VERIFY( &x ); + + BOOST_TEST( x == 3 ); + + BOOST_VERIFY( 0 ); + BOOST_VERIFY( !x ); + BOOST_VERIFY( x == 0 ); + BOOST_VERIFY( !++x ); + BOOST_VERIFY( !f(x) ); + + BOOST_TEST( x == 5 ); + + void * p = 0; + BOOST_VERIFY( p ); +} + +#undef BOOST_DISABLE_ASSERTS + +#define BOOST_ENABLE_ASSERT_HANDLER +#include +#include +#include + +int handler_invoked = 0; + +void boost::assertion_failed(char const * expr, char const * function, char const * file, long line) +{ +#if !defined(BOOST_NO_STDC_NAMESPACE) + using std::printf; +#endif + + printf("Expression: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n", expr, function, file, line); + ++handler_invoked; +} + +struct X +{ + static bool f() + { + BOOST_VERIFY( 0 ); + return false; + } +}; + +void test_handler() +{ + int x = 1; + + BOOST_VERIFY( 1 ); + BOOST_VERIFY( x == 1 ); + BOOST_VERIFY( ++x ); + BOOST_VERIFY( f(x) ); + BOOST_VERIFY( &x ); + + BOOST_TEST( x == 3 ); + + BOOST_VERIFY( 0 ); + BOOST_VERIFY( !x ); + BOOST_VERIFY( x == 0 ); + BOOST_VERIFY( !++x ); + BOOST_VERIFY( !f(x) ); + + BOOST_TEST( x == 5 ); + + void * p = 0; + BOOST_VERIFY( p ); + + BOOST_VERIFY( X::f() ); + + BOOST_TEST( handler_invoked == 8 ); +} + +#undef BOOST_ENABLE_ASSERT_HANDLER + +int main() +{ + test_default(); + test_disabled(); + test_handler(); + + return boost::report_errors(); +} From 6ef45db59d58e2c7b38e02fd7cffff5702bbe67f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 3 Nov 2007 22:47:17 +0000 Subject: [PATCH 25/37] Added a sentence with a brief explanation of the intended uses of BOOST_VERIFY. [SVN r40731] --- assert.html | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/assert.html b/assert.html index e65e791..a970cef 100644 --- a/assert.html +++ b/assert.html @@ -47,13 +47,15 @@ void assertion_failed(char const * expr, char const * function, char const * fil

As is the case with <cassert>, <boost/assert.hpp> can be included multiple times in a single translation unit. BOOST_ASSERT will be redefined each time as specified above.

-

<boost/assert.hpp> also defines the macro BOOST_VERIFY. - It has exactly the same behavior as BOOST_ASSERT, except - that the expression that is passed to BOOST_VERIFY is always - evaluated.

+

<boost/assert.hpp> also defines the macro BOOST_VERIFY. + It has exactly the same behavior as BOOST_ASSERT, except that + the expression that is passed to BOOST_VERIFY is always + evaluated. This is useful when the asserted expression has desirable side + effects; it can also help suppress warnings about unused variables when the + only use of the variable is inside an assertion.


- Copyright © 2002, 2007 by Peter Dimov. Distributed under the Boost - Software License, Version 1.0. See accompanying file - LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.

+ Copyright © 2002, 2007 by Peter Dimov. Distributed under the Boost Software + License, Version 1.0. See accompanying file LICENSE_1_0.txt + or copy at http://www.boost.org/LICENSE_1_0.txt.

From dd8edeacda4f62747171e379c0e3cc02dfe19274 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 14 Nov 2010 18:37:37 +0000 Subject: [PATCH 26/37] Stop inspect complaining that assert is used in BOOST_ASSERT. [SVN r66574] --- include/boost/assert.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/boost/assert.hpp b/include/boost/assert.hpp index c227f17..584a756 100644 --- a/include/boost/assert.hpp +++ b/include/boost/assert.hpp @@ -13,6 +13,12 @@ // See http://www.boost.org/libs/utility/assert.html for documentation. // +// +// Stop inspect complaining about use of 'assert': +// +// boostinspect:naassert_macro +// + #undef BOOST_ASSERT #if defined(BOOST_DISABLE_ASSERTS) From fada0c51253bc1859f52801a1bae0dd80ac22794 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Mon, 24 Jan 2011 15:37:13 +0000 Subject: [PATCH 27/37] Add BOOST_ASSERT_MSG. Add macros to configure output stream. [SVN r68414] --- assert.html | 74 ++++++++++++++++++++++++++++++----- assert_test.cpp | 45 ++++++++++++++++++++++ include/boost/assert.hpp | 83 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 188 insertions(+), 14 deletions(-) diff --git a/assert.html b/assert.html index a970cef..aa3cbf2 100644 --- a/assert.html +++ b/assert.html @@ -17,36 +17,89 @@
- boost.png (6897 bytes) + boost.png (6897 bytes) +

current_function.hpp

 
+

+ BOOST_ASSERT
+ BOOST_ASSERT_MSG
+ BOOST_VERIFY

+ +

BOOST_ASSERT

The header <boost/assert.hpp> defines the macro BOOST_ASSERT, which is similar to the standard assert macro defined in <cassert>. - The macro is intended to be used in Boost libraries. + The macro is intended to be used in both Boost libraries and user + code.

By default, BOOST_ASSERT(expr) is equivalent to assert(expr).

-

When the macro BOOST_DISABLE_ASSERTS is defined when <boost/assert.hpp> +

If the macro BOOST_DISABLE_ASSERTS is defined when <boost/assert.hpp> is included, BOOST_ASSERT(expr) is defined as ((void)0). This allows users to selectively disable BOOST_ASSERT without affecting the definition of the standard assert.

-

When the macro BOOST_ENABLE_ASSERT_HANDLER is defined when <boost/assert.hpp> +

If the macro BOOST_ENABLE_ASSERT_HANDLER is defined when <boost/assert.hpp> is included, BOOST_ASSERT(expr) evaluates expr and, if the result is false, evaluates the expression

+

::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)

+

assertion_failed is declared in <boost/assert.hpp> as

-
-namespace boost
+		
+
namespace boost
 {
-
-void assertion_failed(char const * expr, char const * function, char const * file, long line);
-
+  void assertion_failed(char const * expr, char const * function, char const * file, long line);
 }
 
+

but it is never defined. The user is expected to supply an appropriate definition.

As is the case with <cassert>, <boost/assert.hpp> can be included multiple times in a single translation unit. BOOST_ASSERT will be redefined each time as specified above.

+ +

BOOST_ASSERT_MSG

+

+ The header <boost/assert.hpp> defines the macro BOOST_ASSERT_MSG, + which is similar to the standard assert macro defined in <cassert>, + but with an additional macro parameter supplying an error message. The macro is intended to be used in both Boost libraries + and user code. +

+

BOOST_ASSERT_MSG(expr, msg) is equivalent to + ((void)0) if BOOST_DISABLE_ASSERTS or NDEBUG are + defined or expr evaluates to true. If those + macros and BOOST_ENABLE_ASSERT_MSG_HANDLER are not + defined, and expr evaluates to false, an error + message that includes #expr, msg, BOOST_CURRENT_FUNCTION, + __FILE__, and __LINE__ is sent to output stream + BOOST_ASSERT_MSG_OSTREAM + and std::abort() is called.

+

BOOST_ASSERT_MSG_OSTREAM defines the output stream. It defaults to std::cerr. + Integrated development environments (IDE's) like Microsoft Visual Studio + may produce easier to understand output if messages go to a different + stream, such as std::cout. Users may define BOOST_ASSERT_MSG_OSTREAM before including <boost/assert.hpp> + to specify a different output stream. 

+

If the macro BOOST_ENABLE_ASSERT_MSG_HANDLER is defined when <boost/assert.hpp> + is included, instead of sending a error message to an output + stream, this expression is evaluated

+
+

::boost::assertion_failed_msg(#expr, msg, BOOST_CURRENT_FUNCTION, + __FILE__, __LINE__)

+
+

assertion_failed_msg is declared in <boost/assert.hpp> + as

+
+
namespace boost
+{
+  void assertion_failed_msg(char const * expr, char const * msg, char const * function, char const * file, long line);
+}
+
+
+

but it is never defined. The user is expected to supply an appropriate + definition.

+

As is the case with <cassert>, <boost/assert.hpp> + can be included multiple times in a single translation unit. BOOST_ASSERT_MSG + will be redefined each time as specified above.

+ +

BOOST_VERIFY

<boost/assert.hpp> also defines the macro BOOST_VERIFY. It has exactly the same behavior as BOOST_ASSERT, except that the expression that is passed to BOOST_VERIFY is always @@ -54,8 +107,9 @@ void assertion_failed(char const * expr, char const * function, char const * fil effects; it can also help suppress warnings about unused variables when the only use of the variable is inside an assertion.


- Copyright © 2002, 2007 by Peter Dimov. Distributed under the Boost Software + Copyright © 2002, 2007 by Peter Dimov.  Copyright © 2011 + by Beman Dawes. Distributed under the Boost Software License, Version 1.0. See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.

- + \ No newline at end of file diff --git a/assert_test.cpp b/assert_test.cpp index 693adc4..a0e1e04 100644 --- a/assert_test.cpp +++ b/assert_test.cpp @@ -2,6 +2,7 @@ // assert_test.cpp - a test for boost/assert.hpp // // Copyright (c) 2002 Peter Dimov and Multi Media Ltd. +// Copyright (2) Beman Dawes 2011 // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -20,6 +21,11 @@ void test_default() BOOST_ASSERT(x); BOOST_ASSERT(x == 1); BOOST_ASSERT(&x); + + BOOST_ASSERT_MSG(1, "msg"); + BOOST_ASSERT_MSG(x, "msg"); + BOOST_ASSERT_MSG(x == 1, "msg"); + BOOST_ASSERT_MSG(&x, "msg"); } #define BOOST_DISABLE_ASSERTS @@ -34,13 +40,23 @@ void test_disabled() BOOST_ASSERT(x == 1); BOOST_ASSERT(&x); + BOOST_ASSERT_MSG(1, "msg"); + BOOST_ASSERT_MSG(x, "msg"); + BOOST_ASSERT_MSG(x == 1, "msg"); + BOOST_ASSERT_MSG(&x, "msg"); + BOOST_ASSERT(0); BOOST_ASSERT(!x); BOOST_ASSERT(x == 0); + BOOST_ASSERT_MSG(0, "msg"); + BOOST_ASSERT_MSG(!x, "msg"); + BOOST_ASSERT_MSG(x == 0, "msg"); + void * p = 0; BOOST_ASSERT(p); + BOOST_ASSERT_MSG(p, "msg"); // supress warnings p = &x; @@ -50,11 +66,13 @@ void test_disabled() #undef BOOST_DISABLE_ASSERTS #define BOOST_ENABLE_ASSERT_HANDLER +#define BOOST_ENABLE_ASSERT_MSG_HANDLER #include #include #include int handler_invoked = 0; +int msg_handler_invoked = 0; void boost::assertion_failed(char const * expr, char const * function, char const * file, long line) { @@ -66,11 +84,24 @@ void boost::assertion_failed(char const * expr, char const * function, char cons ++handler_invoked; } +void boost::assertion_failed_msg(char const * expr, char const * msg, char const * function, + char const * file, long line) +{ +#if !defined(BOOST_NO_STDC_NAMESPACE) + using std::printf; +#endif + + printf("Expression: %s Message: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n", + expr, msg, function, file, line); + ++msg_handler_invoked; +} + struct X { static void f() { BOOST_ASSERT(0); + BOOST_ASSERT_MSG(0, "msg f()"); } }; @@ -83,21 +114,35 @@ void test_handler() BOOST_ASSERT(x == 1); BOOST_ASSERT(&x); + BOOST_ASSERT_MSG(1, "msg2"); + BOOST_ASSERT_MSG(x, "msg3"); + BOOST_ASSERT_MSG(x == 1, "msg4"); + BOOST_ASSERT_MSG(&x, "msg5"); + BOOST_ASSERT(0); BOOST_ASSERT(!x); BOOST_ASSERT(x == 0); + BOOST_ASSERT_MSG(0,"msg 0"); + BOOST_ASSERT_MSG(!x, "msg !x"); + BOOST_ASSERT_MSG(x == 0, "msg x == 0"); + void * p = 0; BOOST_ASSERT(p); + BOOST_ASSERT_MSG(p, "msg p"); X::f(); BOOST_ASSERT(handler_invoked == 5); BOOST_TEST(handler_invoked == 5); + + BOOST_ASSERT_MSG(msg_handler_invoked == 5, "msg_handler_invoked count is wrong"); + BOOST_TEST(msg_handler_invoked == 5); } #undef BOOST_ENABLE_ASSERT_HANDLER +#undef BOOST_ENABLE_ASSERT_MSG_HANDLER int main() { diff --git a/include/boost/assert.hpp b/include/boost/assert.hpp index 584a756..a04e2e4 100644 --- a/include/boost/assert.hpp +++ b/include/boost/assert.hpp @@ -1,8 +1,11 @@ // // boost/assert.hpp - BOOST_ASSERT(expr) +// BOOST_ASSERT_MSG(expr, msg) +// BOOST_VERIFY(expr) // // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. // Copyright (c) 2007 Peter Dimov +// Copyright (c) Beman Dawes 2011 // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -19,6 +22,10 @@ // boostinspect:naassert_macro // +//--------------------------------------------------------------------------------------// +// BOOST_ASSERT // +//--------------------------------------------------------------------------------------// + #undef BOOST_ASSERT #if defined(BOOST_DISABLE_ASSERTS) @@ -31,18 +38,86 @@ namespace boost { - -void assertion_failed(char const * expr, char const * function, char const * file, long line); // user defined - + void assertion_failed(char const * expr, + char const * function, char const * file, long line); // user defined } // namespace boost -#define BOOST_ASSERT(expr) ((expr)? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)) +#define BOOST_ASSERT(expr) ((expr) \ + ? ((void)0) \ + : ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)) #else # include // .h to support old libraries w/o - effect is the same # define BOOST_ASSERT(expr) assert(expr) #endif +//--------------------------------------------------------------------------------------// +// BOOST_ASSERT_MSG // +//--------------------------------------------------------------------------------------// + +# undef BOOST_ASSERT_MSG + +#if defined(BOOST_DISABLE_ASSERTS) || defined(NDEBUG) + + #define BOOST_ASSERT_MSG(expr, msg) ((void)0) + +#elif defined(BOOST_ENABLE_ASSERT_MSG_HANDLER) + + #include + + namespace boost + { + void assertion_failed_msg(char const * expr, char const * msg, + char const * function, char const * file, long line); // user defined + } // namespace boost + + #define BOOST_ASSERT_MSG(expr, msg) ((expr) \ + ? ((void)0) \ + : ::boost::assertion_failed_msg(#expr, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)) + +#else + #ifndef BOOST_ASSERT_HPP + #define BOOST_ASSERT_HPP + #include + #include + #include + + // IDE's like Visual Studio perform better if output goes to std::cout or + // some other stream, so allow user to configure output stream: + #ifndef BOOST_ASSERT_MSG_OSTREAM + # define BOOST_ASSERT_MSG_OSTREAM std::cerr + #endif + + namespace boost + { + namespace assertion + { + namespace detail + { + inline void assertion_failed_msg(char const * expr, char const * msg, char const * function, + char const * file, long line) + { + BOOST_ASSERT_MSG_OSTREAM + << "***** Internal Program Error - assertion (" << expr << ") failed in " + << function << ":\n" + << file << '(' << line << "): " << msg << std::endl; + std::abort(); + } + } // detail + } // assertion + } // detail + #endif + + #define BOOST_ASSERT_MSG(expr, msg) ((expr) \ + ? ((void)0) \ + : ::boost::assertion::detail::assertion_failed_msg(#expr, msg, \ + BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)) +#endif + +//--------------------------------------------------------------------------------------// +// BOOST_VERIFY // +//--------------------------------------------------------------------------------------// + #undef BOOST_VERIFY #if defined(BOOST_DISABLE_ASSERTS) || ( !defined(BOOST_ENABLE_ASSERT_HANDLER) && defined(NDEBUG) ) From 50416333b6971ee76f028a8d745629cc1d0a3482 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Mon, 24 Jan 2011 20:15:36 +0000 Subject: [PATCH 28/37] Remove BOOST_ENABLE_ASSERT_MSG_HANDLER; use BOOST_ENABLE_ASSERT_HANDLER in its stead [SVN r68423] --- assert.html | 4 ++-- assert_test.cpp | 1 - include/boost/assert.hpp | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/assert.html b/assert.html index aa3cbf2..5f3f6e7 100644 --- a/assert.html +++ b/assert.html @@ -66,7 +66,7 @@

BOOST_ASSERT_MSG(expr, msg) is equivalent to ((void)0) if BOOST_DISABLE_ASSERTS or NDEBUG are defined or expr evaluates to true. If those - macros and BOOST_ENABLE_ASSERT_MSG_HANDLER are not + macros and BOOST_ENABLE_ASSERT_HANDLER are not defined, and expr evaluates to false, an error message that includes #expr, msg, BOOST_CURRENT_FUNCTION, __FILE__, and __LINE__ is sent to output stream @@ -77,7 +77,7 @@ may produce easier to understand output if messages go to a different stream, such as std::cout. Users may define BOOST_ASSERT_MSG_OSTREAM before including <boost/assert.hpp> to specify a different output stream. 

-

If the macro BOOST_ENABLE_ASSERT_MSG_HANDLER is defined when <boost/assert.hpp> +

If the macro BOOST_ENABLE_ASSERT_HANDLER is defined when <boost/assert.hpp> is included, instead of sending a error message to an output stream, this expression is evaluated

diff --git a/assert_test.cpp b/assert_test.cpp index a0e1e04..26051ac 100644 --- a/assert_test.cpp +++ b/assert_test.cpp @@ -66,7 +66,6 @@ void test_disabled() #undef BOOST_DISABLE_ASSERTS #define BOOST_ENABLE_ASSERT_HANDLER -#define BOOST_ENABLE_ASSERT_MSG_HANDLER #include #include #include diff --git a/include/boost/assert.hpp b/include/boost/assert.hpp index a04e2e4..174f084 100644 --- a/include/boost/assert.hpp +++ b/include/boost/assert.hpp @@ -61,7 +61,7 @@ namespace boost #define BOOST_ASSERT_MSG(expr, msg) ((void)0) -#elif defined(BOOST_ENABLE_ASSERT_MSG_HANDLER) +#elif defined(BOOST_ENABLE_ASSERT_HANDLER) #include From 00ec072fc9ceefc38748d0ed6344ae799e956401 Mon Sep 17 00:00:00 2001 From: David Deakins Date: Fri, 18 Feb 2011 03:46:55 +0000 Subject: [PATCH 29/37] Revised the assertion_failed_msg function to use std::exit(-1) instead of std::abort() for Windows CE (since Windows CE does not have an abort() function in the CRT library) [SVN r68982] --- include/boost/assert.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/boost/assert.hpp b/include/boost/assert.hpp index 174f084..a233505 100644 --- a/include/boost/assert.hpp +++ b/include/boost/assert.hpp @@ -101,7 +101,12 @@ namespace boost << "***** Internal Program Error - assertion (" << expr << ") failed in " << function << ":\n" << file << '(' << line << "): " << msg << std::endl; - std::abort(); + #ifdef UNDER_CE + // The Windows CE CRT library does not have abort() so use exit(-1) instead. + std::exit(-1); + #else + std::abort(); + #endif } } // detail } // assertion From 50e523b1bc6bdfdd43bbcf16b8b4f9e4d4848c2b Mon Sep 17 00:00:00 2001 From: John Maddock Date: Tue, 14 Jun 2011 08:27:14 +0000 Subject: [PATCH 30/37] Apply patch from #5607. Refs #5607. [SVN r72580] --- include/boost/current_function.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/boost/current_function.hpp b/include/boost/current_function.hpp index aa5756e..cb36e35 100644 --- a/include/boost/current_function.hpp +++ b/include/boost/current_function.hpp @@ -28,7 +28,7 @@ namespace detail inline void current_function_helper() { -#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) +#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) || defined(__ghs__) # define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__ @@ -65,3 +65,4 @@ inline void current_function_helper() } // namespace boost #endif // #ifndef BOOST_CURRENT_FUNCTION_HPP_INCLUDED + From 8105f2e314b6503636eb35b2f2b07aa6ef48ee36 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Thu, 14 Mar 2013 17:46:52 +0000 Subject: [PATCH 31/37] Assert: take care of #7028. [SVN r83428] --- include/boost/assert.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/assert.hpp b/include/boost/assert.hpp index a233505..ed8294f 100644 --- a/include/boost/assert.hpp +++ b/include/boost/assert.hpp @@ -28,7 +28,7 @@ #undef BOOST_ASSERT -#if defined(BOOST_DISABLE_ASSERTS) +#if defined(BOOST_DISABLE_ASSERTS) || defined(NDEBUG) # define BOOST_ASSERT(expr) ((void)0) @@ -89,9 +89,9 @@ namespace boost #endif namespace boost - { - namespace assertion - { + { + namespace assertion + { namespace detail { inline void assertion_failed_msg(char const * expr, char const * msg, char const * function, From 5bfb183ec595fee80f33d620424901b5478c9c93 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Thu, 14 Mar 2013 22:27:04 +0000 Subject: [PATCH 32/37] Assert: rollback [82428]. [SVN r83431] --- include/boost/assert.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/assert.hpp b/include/boost/assert.hpp index ed8294f..c42ea4c 100644 --- a/include/boost/assert.hpp +++ b/include/boost/assert.hpp @@ -28,7 +28,7 @@ #undef BOOST_ASSERT -#if defined(BOOST_DISABLE_ASSERTS) || defined(NDEBUG) +#if defined(BOOST_DISABLE_ASSERTS) # define BOOST_ASSERT(expr) ((void)0) From c78b8b91573aa633799bb5b03316bdab6038b9ef Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Fri, 7 Jun 2013 20:21:24 +0000 Subject: [PATCH 33/37] Optimized BOOST_ASSERT_MSG so that it is more lightweight and doesn't prevent enclosing functions from inlining. Also added branching hints for the checked conditions. [SVN r84682] --- include/boost/assert.hpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/include/boost/assert.hpp b/include/boost/assert.hpp index c42ea4c..ccc776a 100644 --- a/include/boost/assert.hpp +++ b/include/boost/assert.hpp @@ -34,6 +34,7 @@ #elif defined(BOOST_ENABLE_ASSERT_HANDLER) +#include #include namespace boost @@ -42,7 +43,7 @@ namespace boost char const * function, char const * file, long line); // user defined } // namespace boost -#define BOOST_ASSERT(expr) ((expr) \ +#define BOOST_ASSERT(expr) (BOOST_LIKELY(!!(expr)) \ ? ((void)0) \ : ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)) @@ -63,6 +64,7 @@ namespace boost #elif defined(BOOST_ENABLE_ASSERT_HANDLER) + #include #include namespace boost @@ -71,7 +73,7 @@ namespace boost char const * function, char const * file, long line); // user defined } // namespace boost - #define BOOST_ASSERT_MSG(expr, msg) ((expr) \ + #define BOOST_ASSERT_MSG(expr, msg) (BOOST_LIKELY(!!(expr)) \ ? ((void)0) \ : ::boost::assertion_failed_msg(#expr, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)) @@ -80,6 +82,7 @@ namespace boost #define BOOST_ASSERT_HPP #include #include + #include #include // IDE's like Visual Studio perform better if output goes to std::cout or @@ -94,26 +97,28 @@ namespace boost { namespace detail { - inline void assertion_failed_msg(char const * expr, char const * msg, char const * function, + // Note: The template is needed to make the function non-inline and avoid linking errors + template< typename CharT > + BOOST_NOINLINE void assertion_failed_msg(CharT const * expr, char const * msg, char const * function, char const * file, long line) { BOOST_ASSERT_MSG_OSTREAM << "***** Internal Program Error - assertion (" << expr << ") failed in " << function << ":\n" << file << '(' << line << "): " << msg << std::endl; - #ifdef UNDER_CE - // The Windows CE CRT library does not have abort() so use exit(-1) instead. - std::exit(-1); - #else - std::abort(); - #endif +#ifdef UNDER_CE + // The Windows CE CRT library does not have abort() so use exit(-1) instead. + std::exit(-1); +#else + std::abort(); +#endif } } // detail } // assertion } // detail #endif - #define BOOST_ASSERT_MSG(expr, msg) ((expr) \ + #define BOOST_ASSERT_MSG(expr, msg) (BOOST_LIKELY(!!(expr)) \ ? ((void)0) \ : ::boost::assertion::detail::assertion_failed_msg(#expr, msg, \ BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)) From 087f1446ee007c2c91e82232b7c4d9f8006e06a7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 26 Sep 2013 13:02:51 +0000 Subject: [PATCH 34/37] Remove obsolete MSVC check from pragma guard git grep -h -B1 "^#\s*pragma once" | grep -v pragma | sort | uniq is now clean. [SVN r85952] --- include/boost/current_function.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/current_function.hpp b/include/boost/current_function.hpp index cb36e35..2904789 100644 --- a/include/boost/current_function.hpp +++ b/include/boost/current_function.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma once #endif From 6dc5368e221eb80ef3772cb144145a0b9a41b355 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 30 Sep 2013 00:36:13 +0000 Subject: [PATCH 35/37] Remove check for obsolete DMC version. [SVN r86043] --- include/boost/current_function.hpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/include/boost/current_function.hpp b/include/boost/current_function.hpp index 2904789..7b0d918 100644 --- a/include/boost/current_function.hpp +++ b/include/boost/current_function.hpp @@ -28,11 +28,7 @@ namespace detail inline void current_function_helper() { -#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) || defined(__ghs__) - -# define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__ - -#elif defined(__DMC__) && (__DMC__ >= 0x810) +#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) || defined(__ghs__) || defined(__DMC__) # define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__ From 8de3bfebff433038a4811e390aa2775b1ed973e6 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 11 Dec 2013 00:13:48 +0200 Subject: [PATCH 36/37] Revert "Remove obsolete MSVC check from pragma guard" This reverts commit 1fd5883b345a3c230daaad8ee93af5bc8f3209d5. --- include/boost/current_function.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/current_function.hpp b/include/boost/current_function.hpp index 7b0d918..a135881 100644 --- a/include/boost/current_function.hpp +++ b/include/boost/current_function.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif From 4bc861adc630d2055fa86bd74e396dd353f05052 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 11 Dec 2013 00:18:49 +0200 Subject: [PATCH 37/37] Revert "Remove check for obsolete DMC version." This reverts commit 4dc965909729ad0d7e1c669bbc4383d33ebe97c9. --- include/boost/current_function.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/boost/current_function.hpp b/include/boost/current_function.hpp index a135881..cb36e35 100644 --- a/include/boost/current_function.hpp +++ b/include/boost/current_function.hpp @@ -28,7 +28,11 @@ namespace detail inline void current_function_helper() { -#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) || defined(__ghs__) || defined(__DMC__) +#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) || defined(__ghs__) + +# define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__ + +#elif defined(__DMC__) && (__DMC__ >= 0x810) # define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__