From 025db91843e3d8f4bf5d7d3842482a3794785576 Mon Sep 17 00:00:00 2001
From: Peter Dimov
-
+
+
+
+
+ Expands to the equivalent of Table of Contents Last revised: July 21, 2017 at 18:08:20 GMT Last revised: December 03, 2017 at 22:51:50 GMT
+
+
BOOST_EXPLICIT_TEMPLATE_TYPE(t)
BOOST_EXPLICIT_TEMPLATE_NON_TYPE(t,v)
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(t)
BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t,v)
+ BOOST_EXPLICIT_TEMPLATE_TYPE(t)
+ BOOST_EXPLICIT_TEMPLATE_NON_TYPE(t,v)
+ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(t)
+ BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t,v)
@@ -4452,6 +4473,8 @@
@@ -4520,6 +4543,22 @@
BOOST_LIKELY(X)
+ BOOST_UNLIKELY(X)
+
@@ -5884,7 +5923,7 @@
Macros
for libraries with separate source code
-
+
+BOOST_PRAGMA_MESSAGE(M)
+
+
+#pragma
+ message(M)
.
+ M
must be a string
+ literal. Example: BOOST_PRAGMA_MESSAGE("This header
+ is deprecated.")
.
+
+
+
+
+
diff --git a/doc/html/index.html b/doc/html/index.html
index 109e2013..12c33f3d 100644
--- a/doc/html/index.html
+++ b/doc/html/index.html
@@ -3,7 +3,7 @@
+
@@ -127,7 +127,7 @@
Configuring
Boost for Your Platform
-
+
diff --git a/doc/macro_reference.qbk b/doc/macro_reference.qbk
index 94d0ca20..a3335447 100644
--- a/doc/macro_reference.qbk
+++ b/doc/macro_reference.qbk
@@ -1095,8 +1095,11 @@ In either case this macro has no effect on runtime behavior and performance
of code.
]]
[[`BOOST_EXPLICIT_TEMPLATE_TYPE(t)`
+
`BOOST_EXPLICIT_TEMPLATE_NON_TYPE(t,v)`
+
`BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(t)`
+
`BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t,v)`][
Some compilers silently "fold" different function template instantiations if
some of the template parameters don't appear in the function parameter list.
@@ -1247,6 +1250,7 @@ If the compiler does not support this markup, `BOOST_NORETURN` is defined empty
additional macro `BOOST_NO_NORETURN` is defined.
]]
[[`BOOST_LIKELY(X)`
+
`BOOST_UNLIKELY(X)`][
These macros communicate to the compiler that the conditional expression `X` is likely
or unlikely to yield a positive result. The expression should result in a boolean value.
@@ -1275,6 +1279,8 @@ Usage example:
typedef unsigned int BOOST_MAY_ALIAS aliasing_uint;
``
]]
+[[`BOOST_PRAGMA_MESSAGE(M)`][Expands to the equivalent of `#pragma message(M)`. `M` must
+be a string literal. Example: `BOOST_PRAGMA_MESSAGE("This header is deprecated.")`.]]
]
[endsect]
diff --git a/include/boost/config/pragma_message.hpp b/include/boost/config/pragma_message.hpp
new file mode 100644
index 00000000..a6292fd0
--- /dev/null
+++ b/include/boost/config/pragma_message.hpp
@@ -0,0 +1,24 @@
+#ifndef BOOST_CONFIG_PRAGMA_MESSAGE_HPP_INCLUDED
+#define BOOST_CONFIG_PRAGMA_MESSAGE_HPP_INCLUDED
+
+// Copyright 2017 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
+//
+// BOOST_PRAGMA_MESSAGE("message")
+
+#if defined(__GNUC__)
+#define BOOST_PRAGMA_MESSAGE_IMPL_1(x) _Pragma(#x)
+#define BOOST_PRAGMA_MESSAGE(x) BOOST_PRAGMA_MESSAGE_IMPL_1(message(x))
+#elif defined(_MSC_VER)
+#define BOOST_PRAGMA_MESSAGE_IMPL_2(x, f, ln) __pragma(message(f "(" #ln "): note: " x))
+#define BOOST_PRAGMA_MESSAGE_IMPL_1(x, f, ln) BOOST_PRAGMA_MESSAGE_IMPL_2(x, f, ln)
+#define BOOST_PRAGMA_MESSAGE(x) BOOST_PRAGMA_MESSAGE_IMPL_1(x, __FILE__, __LINE__)
+#else
+#define BOOST_PRAGMA_MESSAGE(x)
+#endif
+
+#endif // BOOST_CONFIG_PRAGMA_MESSAGE_HPP_INCLUDED
diff --git a/test/Jamfile.v2 b/test/Jamfile.v2
index 09422bfc..16147352 100644
--- a/test/Jamfile.v2
+++ b/test/Jamfile.v2
@@ -103,6 +103,7 @@ test-suite config
[ run cstdint_test2.cpp : : :
#include <boost/detail/workaround.hpp> +#include <boost/config/workaround.hpp>usage is then: @@ -3999,7 +3999,7 @@
Note: the ultimate source of documentation - for this macro is in boost/detail/workaround.hpp. + for this macro is in boost/config/workaround.hpp.
@@ -4551,7 +4551,8 @@- Expands to the equivalent of
#pragma + Defined in header
<boost/config/pragma_message.hpp>
, + this macro expands to the equivalent of#pragma message(M)
.M
must be a string literal. Example:BOOST_PRAGMA_MESSAGE("This header diff --git a/doc/html/index.html b/doc/html/index.html index 12c33f3d..d75d10cc 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -992,7 +992,7 @@
- + Last revised: December 03, 2017 at 22:51:50 GMT
Last revised: December 03, 2017 at 23:12:48 GMT
diff --git a/doc/macro_reference.qbk b/doc/macro_reference.qbk index a3335447..3d4a1ce7 100644 --- a/doc/macro_reference.qbk +++ b/doc/macro_reference.qbk @@ -979,7 +979,7 @@ workarounds for compiler/standard library defects. This macro is used where a compiler specific workaround is required that is not otherwise described by one of the other Boost.Config macros. To use the macro you must first `` -#include+#include `` usage is then: `` @@ -1001,7 +1001,7 @@ For example of `__BORLANDC__` /unless/ the macro `BOOST_DETECT_OUTDATED_WORKAROUNDS` is defined, in which case evaluates to `(__BORLANDC__ <= 0x590)`. -[*Note]: the ultimate source of documentation for this macro is in [@../../../../boost/detail/workaround.hpp boost/detail/workaround.hpp]. +[*Note]: the ultimate source of documentation for this macro is in [@../../../../boost/config/workaround.hpp boost/config/workaround.hpp]. ]] [[`BOOST_PREVENT_MACRO_SUBSTITUTION`][ Sometimes you have a function name with the same name as a C macro, for example "min" and "max" @@ -1279,8 +1279,9 @@ Usage example: typedef unsigned int BOOST_MAY_ALIAS aliasing_uint; `` ]] -[[`BOOST_PRAGMA_MESSAGE(M)`][Expands to the equivalent of `#pragma message(M)`. `M` must -be a string literal. Example: `BOOST_PRAGMA_MESSAGE("This header is deprecated.")`.]] +[[`BOOST_PRAGMA_MESSAGE(M)`][Defined in header ` `, +this macro expands to the equivalent of `#pragma message(M)`. `M` must be a string +literal. Example: `BOOST_PRAGMA_MESSAGE("This header is deprecated.")`.]] ] [endsect] From 08bd1dbe71f1067c43804455f207a74f1c34740a Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 4 Dec 2017 18:05:05 +0200 Subject: [PATCH 3/4] Move BOOST_STRINGIZE, BOOST_JOIN to config/helper_macros.hpp; use BOOST_STRINGIZE in BOOST_PRAGMA_MESSAGE --- include/boost/config/detail/suffix.hpp | 19 ++----------- include/boost/config/helper_macros.hpp | 37 +++++++++++++++++++++++++ include/boost/config/pragma_message.hpp | 13 +++++---- test/Jamfile.v2 | 1 + test/helper_macros_test.cpp | 30 ++++++++++++++++++++ 5 files changed, 78 insertions(+), 22 deletions(-) create mode 100644 include/boost/config/helper_macros.hpp create mode 100644 test/helper_macros_test.cpp diff --git a/include/boost/config/detail/suffix.hpp b/include/boost/config/detail/suffix.hpp index caa0b229..4aeac4c7 100644 --- a/include/boost/config/detail/suffix.hpp +++ b/include/boost/config/detail/suffix.hpp @@ -537,25 +537,10 @@ namespace std{ using ::type_info; } // ---------------------------------------------------------------------------// -// // Helper macro BOOST_STRINGIZE: -// Converts the parameter X to a string after macro replacement -// on X has been performed. -// -#define BOOST_STRINGIZE(X) BOOST_DO_STRINGIZE(X) -#define BOOST_DO_STRINGIZE(X) #X - -// // Helper macro BOOST_JOIN: -// The following piece of macro magic joins the two -// arguments together, even when one of the arguments is -// itself a macro (see 16.3.1 in C++ standard). The key -// is that macro expansion of macro arguments does not -// occur in BOOST_DO_JOIN2 but does in BOOST_DO_JOIN. -// -#define BOOST_JOIN( X, Y ) BOOST_DO_JOIN( X, Y ) -#define BOOST_DO_JOIN( X, Y ) BOOST_DO_JOIN2(X,Y) -#define BOOST_DO_JOIN2( X, Y ) X##Y + +#include // // Set some default values for compiler/library/platform names. diff --git a/include/boost/config/helper_macros.hpp b/include/boost/config/helper_macros.hpp new file mode 100644 index 00000000..3e79526d --- /dev/null +++ b/include/boost/config/helper_macros.hpp @@ -0,0 +1,37 @@ +#ifndef BOOST_CONFIG_HELPER_MACROS_HPP_INCLUDED +#define BOOST_CONFIG_HELPER_MACROS_HPP_INCLUDED + +// Copyright 2001 John Maddock. +// Copyright 2017 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 +// +// BOOST_STRINGIZE(X) +// BOOST_JOIN(X, Y) +// +// Note that this header is C compatible. + +// +// Helper macro BOOST_STRINGIZE: +// Converts the parameter X to a string after macro replacement +// on X has been performed. +// +#define BOOST_STRINGIZE(X) BOOST_DO_STRINGIZE(X) +#define BOOST_DO_STRINGIZE(X) #X + +// +// Helper macro BOOST_JOIN: +// The following piece of macro magic joins the two +// arguments together, even when one of the arguments is +// itself a macro (see 16.3.1 in C++ standard). The key +// is that macro expansion of macro arguments does not +// occur in BOOST_DO_JOIN2 but does in BOOST_DO_JOIN. +// +#define BOOST_JOIN(X, Y) BOOST_DO_JOIN(X, Y) +#define BOOST_DO_JOIN(X, Y) BOOST_DO_JOIN2(X,Y) +#define BOOST_DO_JOIN2(X, Y) X##Y + +#endif // BOOST_CONFIG_HELPER_MACROS_HPP_INCLUDED diff --git a/include/boost/config/pragma_message.hpp b/include/boost/config/pragma_message.hpp index a6292fd0..448ccc0f 100644 --- a/include/boost/config/pragma_message.hpp +++ b/include/boost/config/pragma_message.hpp @@ -9,14 +9,17 @@ // http://www.boost.org/LICENSE_1_0.txt // // BOOST_PRAGMA_MESSAGE("message") +// +// Expands to the equivalent of #pragma message("message") +// +// Note that this header is C compatible. + +#include #if defined(__GNUC__) -#define BOOST_PRAGMA_MESSAGE_IMPL_1(x) _Pragma(#x) -#define BOOST_PRAGMA_MESSAGE(x) BOOST_PRAGMA_MESSAGE_IMPL_1(message(x)) +#define BOOST_PRAGMA_MESSAGE(x) _Pragma(BOOST_STRINGIZE(message(x))) #elif defined(_MSC_VER) -#define BOOST_PRAGMA_MESSAGE_IMPL_2(x, f, ln) __pragma(message(f "(" #ln "): note: " x)) -#define BOOST_PRAGMA_MESSAGE_IMPL_1(x, f, ln) BOOST_PRAGMA_MESSAGE_IMPL_2(x, f, ln) -#define BOOST_PRAGMA_MESSAGE(x) BOOST_PRAGMA_MESSAGE_IMPL_1(x, __FILE__, __LINE__) +#define BOOST_PRAGMA_MESSAGE(x) __pragma(message(__FILE__ "(" BOOST_STRINGIZE(__LINE__) "): note: " x)) #else #define BOOST_PRAGMA_MESSAGE(x) #endif diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 16147352..9f1e4ea4 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -103,6 +103,7 @@ test-suite config [ run cstdint_test2.cpp : : : all gcc: "-Wno-long-long -Wextra" darwin: -Wno-long-long ] [ compile cstdint_include_test.cpp : all gcc: -Wextra ] [ run config_build_check.cpp : : : [ requires int128 cxx11_constexpr cxx11_user_defined_literals ] ] + [ run helper_macros_test.cpp ] [ compile pragma_message_test.cpp ] ; diff --git a/test/helper_macros_test.cpp b/test/helper_macros_test.cpp new file mode 100644 index 00000000..5bbea8dd --- /dev/null +++ b/test/helper_macros_test.cpp @@ -0,0 +1,30 @@ +// Copyright 2017 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 main() +{ +#define X pumpkin + + BOOST_TEST_CSTR_EQ( BOOST_STRINGIZE(X), "pumpkin" ); + BOOST_TEST_CSTR_EQ( BOOST_STRINGIZE(__LINE__), "16" ); + +#define Y 2 + + int BOOST_JOIN(X, Y) = 0; + (void)pumpkin2; + + int BOOST_JOIN(X, __LINE__) = 0; + (void)pumpkin23; + + BOOST_TEST_CSTR_EQ( BOOST_STRINGIZE(BOOST_JOIN(X, Y)), "pumpkin2" ); + BOOST_TEST_CSTR_EQ( BOOST_STRINGIZE(BOOST_JOIN(X, __LINE__)), "pumpkin27" ); + + return boost::report_errors(); +} From 23327d6d0169c73ace8f7b91a40f03f4de4839fa Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 4 Dec 2017 19:15:36 +0200 Subject: [PATCH 4/4] Suppress BOOST_PRAGMA_MESSAGE messages when BOOST_DISABLE_PRAGMA_MESSAGE is defined --- include/boost/config/pragma_message.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/boost/config/pragma_message.hpp b/include/boost/config/pragma_message.hpp index 448ccc0f..d213f63c 100644 --- a/include/boost/config/pragma_message.hpp +++ b/include/boost/config/pragma_message.hpp @@ -16,12 +16,14 @@ #include -#if defined(__GNUC__) -#define BOOST_PRAGMA_MESSAGE(x) _Pragma(BOOST_STRINGIZE(message(x))) +#if defined(BOOST_DISABLE_PRAGMA_MESSAGE) +# define BOOST_PRAGMA_MESSAGE(x) +#elif defined(__GNUC__) +# define BOOST_PRAGMA_MESSAGE(x) _Pragma(BOOST_STRINGIZE(message(x))) #elif defined(_MSC_VER) -#define BOOST_PRAGMA_MESSAGE(x) __pragma(message(__FILE__ "(" BOOST_STRINGIZE(__LINE__) "): note: " x)) +# define BOOST_PRAGMA_MESSAGE(x) __pragma(message(__FILE__ "(" BOOST_STRINGIZE(__LINE__) "): note: " x)) #else -#define BOOST_PRAGMA_MESSAGE(x) +# define BOOST_PRAGMA_MESSAGE(x) #endif #endif // BOOST_CONFIG_PRAGMA_MESSAGE_HPP_INCLUDED