c++ - Disable exception working for boost::smart_ptr but not for boost::property_tree -


i'm using boost 1.57. need disable exception support in not widely-used proprietary compiler. when needed use boost::smart_ptr, following steps worked charm:

  1. disabled c++11 support using following user.hpp file (compiling -dboost_user_config="<user.hpp>"):

    #define boost_has_nrvo #define boost_no_complete_value_initialization #define boost_no_cxx11_auto_declarations #define boost_no_cxx11_auto_multideclarations #define boost_no_cxx11_char16_t #define boost_no_cxx11_char32_t #define boost_no_cxx11_constexpr #define boost_no_cxx11_decltype #define boost_no_cxx11_decltype_n3276 #define boost_no_cxx11_defaulted_functions #define boost_no_cxx11_deleted_functions #define boost_no_cxx11_explicit_conversion_operators #define boost_no_cxx11_final #define boost_no_cxx11_function_template_default_args #define boost_no_cxx11_lambdas #define boost_no_cxx11_local_class_template_parameters #define boost_no_cxx11_noexcept #define boost_no_cxx11_nullptr #define boost_no_cxx11_range_based_for #define boost_no_cxx11_raw_literals #define boost_no_cxx11_ref_qualifiers #define boost_no_cxx11_rvalue_references #define boost_no_cxx11_scoped_enums #define boost_no_cxx11_static_assert #define boost_no_cxx11_template_aliases #define boost_no_cxx11_unicode_literals #define boost_no_cxx11_unified_initialization_syntax #define boost_no_cxx11_user_defined_literals #define boost_no_cxx11_variadic_macros #define boost_no_cxx11_variadic_templates #define boost_no_sfinae_expr #define boost_no_two_phase_name_lookup 
  2. informs boost libraries not use exceptions: -dboost_no_exceptions -dboost_exception_disable

  3. resulting in following compilation line: mycompiler -dboost_user_config="<user.hpp>" -dboost_no_exceptions -dboost_exception_disable -c foo.cpp -o foo.o

then following piece of code compiled:

#include <iostream> #include <string> #include <boost/shared_ptr.hpp> #include <boost/smart_ptr/make_shared.hpp>  namespace boost {     void throw_exception(std::exception const& e) {         std::cerr << "fake exception: " << e.what() << "\n";         std::exit(255);     } }  class foo {   private:     boost::shared_ptr<int> ptr;   public:     bool bar(const std::string file_name) {       ptr = boost::make_shared<int>();       return true;     } }; 

but when i've tried use above method following source code, compilation goes wrong:

#include <iostream> #include <string> #include <boost/property_tree/ptree.hpp> #include <boost/property_tree/ini_parser.hpp>  namespace boost {     void throw_exception(std::exception const& e) {         std::cerr << "fake exception: " << e.what() << "\n";         std::exit(255);     } }  class foo {     public:       bool bar(const std::string file_name) {            boost::property_tree::ptree prop_tree;         boost::property_tree::read_ini(file_name, prop_tree);          return !prop_tree.empty();       } }; 

resulting following errors instance:

"boost\boost/optional/optional.hpp", line 1047: error:  #312: no suitable user-defined conversion "boost::bad_optional_access" "const std::exception" exists             throw_exception(bad_optional_access());                             ^ "boost\boost/optional/optional.hpp", line 1055: error:  #312: no suitable user-defined conversion "boost::bad_optional_access" "const std::exception" exists             throw_exception(bad_optional_access());                             ^ "boost\boost/type_index/stl_type_index.hpp", line 138: error:  #312: no suitable user-defined conversion "std::runtime_error" "const std::exception" exists           boost::throw_exception(std::runtime_error("type name demangling failed"));                                  ^ "boost\boost/property_tree/ini_parser.hpp", line 168: error:  #540: support exception handling disabled; use --exceptions enable           try {           ^                               

finally question:

why in first case works ok, not in second? how can boost::property_tree compile without exception support? possible?


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -