I want to detect whether or not the -no_exception compile time flag has been used on gcc/clang. Will BOOST_NO_EXCEPTIONS do this? If not is there something I can use? Robert Ramey
On Thu, 24 Oct 2019 at 17:47, Robert Ramey via Boost
I want to detect whether or not the -no_exception compile time flag has been used on gcc/clang. Will BOOST_NO_EXCEPTIONS do this? If not is there something I can use?
A look at the code or a simple Google search allows to answer these questions. Boost.Config will define BOOST_NO_EXCEPTIONS if it is not already defined and it detects that the compiler has exceptions disabled.
On Thu, 24 Oct 2019 at 17:47, Robert Ramey via Boost
I want to detect whether or not the -no_exception compile time flag has been used on gcc/clang. Will BOOST_NO_EXCEPTIONS do this? If not is there something I can use?
A look at the code or a simple Google search allows to answer these questions. Boost.Config will define BOOST_NO_EXCEPTIONS if it is not already defined and it detects that the compiler has exceptions disabled.
Also, If you (Robert) would reverse your decision from 2009 and just let boost::serialization::throw_exception == boost::throw_exception rather than being a copy of the 2002-2009 version, then you won't have to think about these config things - the upstream library does it for you! It seems a bit glasshouses to tell a Boost.JSON to depend Boost.Sprit when you yourself won't accept even this relatively trivial dependency on Boost.ThrowException :-) Pete
On 10/25/19 4:25 AM, Peter Bartlett via Boost wrote:
On Thu, 24 Oct 2019 at 17:47, Robert Ramey via Boost
wrote: I want to detect whether or not the -no_exception compile time flag has been used on gcc/clang. Will BOOST_NO_EXCEPTIONS do this? If not is there something I can use?
A look at the code or a simple Google search allows to answer these questions. Boost.Config will define BOOST_NO_EXCEPTIONS if it is not already defined and it detects that the compiler has exceptions disabled.
Also, If you (Robert) would reverse your decision from 2009 and just let boost::serialization::throw_exception == boost::throw_exception rather than being a copy of the 2002-2009 version, then you won't have to think about these config things - the upstream library does it for you!
Hmmm - I'm not convinced that it does. I was surprised when the original definition of BOOST_THROW_EXCEPTION was altered from a very simple macro to put a common face on some inconsistencies between compilers with a full blown component with lots of new behavior that required a lot of investigation of it's implicatitions. When it happened it broke my code and created all sorts of havoc. That was not a nice thing to do. Established definitions that others depend upon shouldn't be changed without notice. Of course it came at a very inconvenient time for me so that didn't help. I recently looked into the documentation of Boost.Exception and my conclusion was that I'd have to spend a lot of time looking into what it actually does and how it does it to know what the implications of using might be. It certainly didn't shed any light on the current question.
It seems a bit glasshouses to tell a Boost.JSON to depend Boost.Sprit when
I don't think this is a good analogy.
you yourself won't accept even this relatively trivial dependency on Boost.ThrowException :-)
LOL - "trivial dependency" - trivial is in the eye of the beholder. It doesn't look trivial to me. In the first "surprise package" iteration it added 5K lines of header code to every component which used it. I understand that that has since been addressed. But it illustrates the pitfall of injecting one's code into someone else's library without telling them just so you don't have to spend the time convincing them that it's a good thing. I'm sympathetic - make a case for adding one's code takes work, but ambushing them is not a great substitute - it creates resentment and ultimately doesn't help you meet your goal.
Pete
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Robert Ramey wrote:
When it happened it broke my code and created all sorts of havoc.
Not this again. FWIW, your problem is that you're missing a declaration of boost::throw_exception. See https://github.com/boostorg/variant2/blob/a15364bd8148b147e0ba7d27197a36b33d... for example.
On 10/25/19 2:38 AM, Mathias Gaunard via Boost wrote:
On Thu, 24 Oct 2019 at 17:47, Robert Ramey via Boost
wrote: I want to detect whether or not the -no_exception compile time flag has been used on gcc/clang. Will BOOST_NO_EXCEPTIONS do this? If not is there something I can use?
A look at the code or a simple Google search allows to answer these questions. Boost.Config will define BOOST_NO_EXCEPTIONS if it is not already defined and it detects that the compiler has exceptions disabled.
I couldn't see this from looking at the implementation in config.hpp. Maybe I missed it. I think that config.hpp will detect if the compiler doesn't support exceptions. But it doesn't look that it detects when the exceptions are suppressed via the -no-exceptions switch.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
On Fri, 25 Oct 2019, 15:44 Robert Ramey via Boost,
I couldn't see this from looking at the implementation in config.hpp. Maybe I missed it.
It's clearly there. #if !defined(__EXCEPTIONS) and !defined(BOOST_NO_EXCEPTIONS) # define BOOST_NO_EXCEPTIONS #endif and it does similar things for plenty of different compilers, not just GCC or Clang.
On 10/25/19 9:40 AM, Mathias Gaunard via Boost wrote:
On Fri, 25 Oct 2019, 15:44 Robert Ramey via Boost,
wrote: I couldn't see this from looking at the implementation in config.hpp. Maybe I missed it.
It's clearly there.
#if !defined(__EXCEPTIONS) and !defined(BOOST_NO_EXCEPTIONS) # define BOOST_NO_EXCEPTIONS #endif
Right. I did see this. But I didn't (and still don't) know where _EXCEPTIONS is defined.
and it does similar things for plenty of different compilers, not just GCC or Clang.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
On 24. Oct 2019, at 18:47, Robert Ramey via Boost
wrote: I want to detect whether or not the -no_exception compile time flag has been used on gcc/clang. Will BOOST_NO_EXCEPTIONS do this? If not is there something I can use?
Yes, it does. I would not set this compiler flag by hand, you can use b2 exception-handling=off. If you use the BOOST_THROW_EXCEPTION macro, you normally do not need to use BOOST_NO_EXCEPTIONS directly. I use BOOST_NO_EXCEPTIONS in some unit tests of throws to avoid warnings about unused variables. Often it is not needed there as well. BOOST_TEST_THROW from boost/core/lightweight_test.hpp automatically expands to a nothing when BOOST_NO_EXCEPTIONS is set, for example.
On 10/25/19 3:16 AM, Hans Dembinski via Boost wrote:
On 24. Oct 2019, at 18:47, Robert Ramey via Boost
wrote: I want to detect whether or not the -no_exception compile time flag has been used on gcc/clang. Will BOOST_NO_EXCEPTIONS do this? If not is there something I can use?
Yes, it does.
Hmmm - I've written a small test which seems to show that it doesn't.
#include
I would not set this compiler flag by hand, you can use b2 exception-handling=off.
Hmmm - I would not think it's a good idea to make a library component dependent on the user using b2 to build it.
If you use the BOOST_THROW_EXCEPTION macro, you normally do not need to use BOOST_NO_EXCEPTIONS directly. I use BOOST_NO_EXCEPTIONS in some unit tests of throws to avoid warnings about unused variables. Often it is not needed there as well. BOOST_TEST_THROW from boost/core/lightweight_test.hpp automatically expands to a nothing when BOOST_NO_EXCEPTIONS is set, for example.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
On 10/25/19 7:42 AM, Robert Ramey via Boost wrote:
On 10/25/19 3:16 AM, Hans Dembinski via Boost wrote:
On 24. Oct 2019, at 18:47, Robert Ramey via Boost
wrote: I want to detect whether or not the -no_exception compile time flag has been used on gcc/clang. Will BOOST_NO_EXCEPTIONS do this? If not is there something I can use?
Yes, it does.
Hmmm - I've written a small test which seems to show that it doesn't.
#include
#include <exception> int main(int, char *[]){ #ifdef BOOST_NO_EXCEPTIONS throw std::exception(); #endif }
I'm still investigating this.
Looks like I setup my test wrong. Should be
#include
participants (5)
-
Hans Dembinski
-
Mathias Gaunard
-
Peter Bartlett
-
Peter Dimov
-
Robert Ramey