build_boost_visibility000755 010663 000145 00000000521 11575742325 016264 0ustar00jjonesusers000000 000000 #!/bin/bash BOOST_ROOT=//mathworks/hub/3rdparty/R2011b/265524/maci64/boost/include BASE=boost_visibility CXXFLAGS="-Wall -fvisibility=hidden -fPIC -I${BOOST_ROOT}" g++ $CXXFLAGS -c ${BASE}.cpp ${BASE}_main.cpp g++ $CXXFLAGS -shared ${BASE}.o -o lib${BASE}.so g++ $CXXFLAGS ${BASE}_main.o -L. -l${BASE} -o ${BASE} -Wl,-rpath,'$ORIGIN' boost_visibility.cpp000644 010663 000145 00000001277 11575726456 015703 0ustar00jjonesusers000000 000000 #include "boost_visibility.hpp" #include typedef std::exception my_exception; void throw_enable_current() { throw boost::enable_current_exception(my_exception()); } void throw_enable_error (int value) { throw boost::enable_error_info(my_exception()) << my_info(value); } void throw_unknown (int value) { throw boost::unknown_exception() << my_info(value); } void throw_unknown_enable_current (int value) { throw boost::enable_current_exception(boost::unknown_exception()) << my_info(value); } void boost_throw (int value) { try { boost::throw_exception(my_exception()); } catch (boost::exception& ex) { ex << my_info(value); throw; } } boost_visibility.hpp000644 010663 000145 00000001046 11575727213 015672 0ustar00jjonesusers000000 000000 //#pragma GCC visibility push(default) #include //#pragma GCC visibility pop #include #include #define VISIBLE __attribute__((visibility("default"))) struct VISIBLE my_info_tag {}; typedef boost::error_info my_info; VISIBLE void throw_enable_current(); VISIBLE void throw_enable_error(int value); VISIBLE void throw_unknown (int value); VISIBLE void throw_unknown_enable_current(int value); VISIBLE void boost_throw(int value); boost_visibility_main.cpp000644 010663 000145 00000005037 11575726522 016677 0ustar00jjonesusers000000 000000 #include "boost_visibility.hpp" #include template void handle (const char* msg) { std::cout << " " << std::left << std::setw(52) << msg << " : "; try { throw; } catch (const T&) { std::cout << "passed"; } catch (...) { std::cout << "FAILED"; } std::cout << std::endl; } void handle (int value) { try { throw; } catch (const boost::exception& ex) { std::cout << " " << std::right << std::setw(52) << "get_error_info" << " : "; const int* const mi = boost::get_error_info(ex); if (!mi) std::cout << "FAILED (not found)"; else if (*mi != value) std::cout << "FAILED (wrong value)"; else std::cout << "passed"; std::cout << std::endl; } catch (...) {} } template void test_throw_enable_current() { try { throw_enable_current(); } catch (...) { handle("throw enable_current_exception(*)"); } } template void test_throw_enable_error (int value) { try { throw_enable_error(value); } catch (...) { handle("throw enable_error_info(*)"); handle(value); } } template void test_throw_unknown (int value) { try { throw_unknown(value); } catch (...) { handle("throw unknown_exception()"); handle(value); } } template void test_throw_unknown_enable_current (int value) { try { throw_unknown_enable_current(value); } catch (...) { handle("throw enable_current_exception(unknown_exception())"); handle(value); } } template void test_boost_throw (int value) { try { boost_throw(value); } catch (...) { handle("throw_exception(*)"); handle(value); } } void test_clone_base() { typedef boost::exception_detail::clone_base ex_type; std::cout << "Testing for " << typeid(ex_type).name() << std::endl; test_throw_enable_current (); test_throw_unknown_enable_current(1); test_boost_throw (2); std::cout << std::endl; } void test_boost_exception() { typedef boost::exception ex_type; std::cout << "Testing for " << typeid(ex_type).name() << std::endl; test_throw_enable_error (3); test_throw_unknown (4); test_throw_unknown_enable_current(5); test_boost_throw (6); std::cout << std::endl; } int main() { test_clone_base(); test_boost_exception(); }