Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] develop from boostorg:develop #6

Merged
merged 1 commit into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions doc/leaf.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5322,7 +5322,7 @@ NOTE: See also <<BOOST_LEAF_ASSIGN>>.
.#include <boost/leaf/error.hpp>
[source,c++]
----
#ifdef BOOST_LEAF_GNUC_STMTEXPR
#if BOOST_LEAF_CFG_GNUC_STMTEXPR
#define BOOST_LEAF_CHECK(r)\
({\
Expand Down Expand Up @@ -5375,7 +5375,7 @@ leaf::result<float> add_values()
}
----

If `BOOST_LEAF_GNUC_STMTEXPR` is defined (which is the default under `pass:[__GNUC__]`), `BOOST_LEAF_CHECK` expands to a https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html[GNU C statement expression], which allows its use with non-`void` result types in any expression; see <<checking_for_errors>>.
If `BOOST_LEAF_CFG_GNUC_STMTEXPR` is `1` (which is the default under `pass:[__GNUC__]`), `BOOST_LEAF_CHECK` expands to a https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html[GNU C statement expression], which allows its use with non-`void` result types in any expression; see <<checking_for_errors>>.

'''

Expand Down Expand Up @@ -6007,6 +6007,7 @@ The following configuration macros are recognized:
* `BOOST_LEAF_CFG_STD_SYSTEM_ERROR`: Defining this macro as `0` disables the `std::error_code` / `std::error_condition` integration. In this case LEAF does not `#include <system_error>`, which may be too heavy for embedded platforms (if the macro is left undefined, LEAF defines it as `1`).
* `BOOST_LEAF_CFG_STD_STRING`: Defining this macro as `0` disables all use of `std::string` (this requires `BOOST_LEAF_CFG_DIAGNOSTICS=0` as well). In this case LEAF does not `#include <string>` which may be too heavy for embedded platforms (if the macro is left undefined, LEAF defines it as `1`).
* `BOOST_LEAF_CFG_CAPTURE`: Defining this macro as `0` disables the ability of `leaf::result` to transport errors between threads. In this case LEAF does not `#include <memory>`, which may be too heavy for embedded platforms (if the macro is left undefined, LEAF defines it as `1`).
* `BOOST_LEAF_CFG_GNUC_STMTEXPR`: This macro controls whether or not <<BOOST_LEAF_CHECK>> is defined in terms of a https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html[GNU C statement expression], which enables its use to check for errors similarly to how the questionmark operator works in some languages (see <<checking_for_errors>>). By default the macro is defined as `1` under `pass:[__GNUC__]`, otherwise as `0`.
* `BOOST_LEAF_CFG_WIN32`: Defining this macro as 1 enables the default constructor in <<e_LastError>>, and the automatic conversion to string (via `FormatMessageA`) when <<verbose_diagnostic_info>> is printed. If the macro is left undefined, LEAF defines it as `0` (even on windows, since including `windows.h` is generally not desirable). Note that the `e_LastError` type itself is available on all platforms, there is no need for conditional compilation in error handlers that use it.
* `BOOST_LEAF_NO_EXCEPTIONS`: Disables all exception handling support. If left undefined, LEAF defines it automatically based on the compiler configuration (e.g. `-fno-exceptions`).
* `BOOST_LEAF_NO_THREADS`: Disables all thread safety in LEAF.
Expand Down
15 changes: 12 additions & 3 deletions include/boost/leaf/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@
# define BOOST_LEAF_CFG_WIN32 0
#endif

#ifndef BOOST_LEAF_CFG_GNUC_STMTEXPR
# ifdef __GNUC__
# define BOOST_LEAF_CFG_GNUC_STMTEXPR 1
# else
# define BOOST_LEAF_CFG_GNUC_STMTEXPR 0
# endif
#endif

#if BOOST_LEAF_CFG_DIAGNOSTICS!=0 && BOOST_LEAF_CFG_DIAGNOSTICS!=1
# error BOOST_LEAF_CFG_DIAGNOSTICS must be 0 or 1.
#endif
Expand All @@ -97,6 +105,10 @@
# error BOOST_LEAF_CFG_WIN32 must be 0 or 1.
#endif

#if BOOST_LEAF_CFG_GNUC_STMTEXPR!=0 && BOOST_LEAF_CFG_GNUC_STMTEXPR!=1
# error BOOST_LEAF_CFG_GNUC_STMTEXPR must be 0 or 1.
#endif

////////////////////////////////////////

// Configure BOOST_LEAF_NO_EXCEPTIONS, unless already #defined
Expand Down Expand Up @@ -253,9 +265,6 @@

#ifdef __GNUC__
# define BOOST_LEAF_SYMBOL_VISIBLE __attribute__((__visibility__("default")))
# ifndef BOOST_LEAF_GNUC_STMTEXPR
# define BOOST_LEAF_GNUC_STMTEXPR
# endif
#else
# define BOOST_LEAF_SYMBOL_VISIBLE
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/boost/leaf/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#define BOOST_LEAF_AUTO(v, r)\
BOOST_LEAF_ASSIGN(auto v, r)

#ifdef BOOST_LEAF_GNUC_STMTEXPR
#if BOOST_LEAF_CFG_GNUC_STMTEXPR

#define BOOST_LEAF_CHECK(r)\
({\
Expand Down
2 changes: 1 addition & 1 deletion test/BOOST_LEAF_CHECK_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ leaf::result<value> f1( bool success )
return leaf::new_error();
}

#ifdef BOOST_LEAF_GNUC_STMTEXPR
#if BOOST_LEAF_GNUC_STMTEXPR

leaf::result<value> f2( bool success )
{
Expand Down