I have an embeded system and would like to use boost in this system, but need to disable exception because I do not want to pay cost of exception.
Boost has given one user.hpp and settable macro option BOOST_NO_EXCEPTIONS and BOOST_NO_EXCEPTION_STD_NAMESPACE, but boost::shared_ptr can not be compiled(more precisely speaking, can not be linked) if these two macro is defined.
shared_ptr_boost.cpp:(.text._ZN5boost6detail12shared_countC2IiEEPT_[_ZN5boost6detail12shared_countC5IiEEPT_]+0x7a): undefined reference to `boost::throw_exception(std::exception const&)'
collect2: error: ld returned 1 exit status
why does boost give macro options but do not promise compilation with those options?
It can be compiled.
It just cannot be linked.
That is because if you define BOOST_NO_EXCEPTIONS, you'll have to provide the implementation of boost::throw_exception(std::exception const&)
somewhere, to replace the usual error raising facilities.
Have a read through the comments in throw_exception.hpp:
namespace boost
{
#ifdef BOOST_NO_EXCEPTIONS
void throw_exception(std::exception const & e); // user defined
#else
//[Not user defined --Dynguss]
template<class E> inline void throw_exception(E const & e)
{
throw e;
}
#endif
} // namespace boost
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With