build_boost_visibility0000755001066300001450000000037311435266610015002 0ustar jjonesusers#!/bin/bash BOOST_INC=$1 BASE=boost_visibility CXXFLAGS="-Wall -pedantic -fPIC -fvisibility=hidden -I${BOOST_INC}" g++ $CXXFLAGS -c ${BASE}.cpp g++ $CXXFLAGS -shared ${BASE}.o -o lib${BASE}.so g++ $CXXFLAGS ${BASE}_main.cpp -L. -l${BASE} -o ${BASE} boost_visibility.hpp0000644001066300001450000000054111431062541014374 0ustar jjonesusers//#pragma GCC visibility push (default) // uncomment to fix #include #include //#pragma GCC visibility pop // uncomment to fix struct __attribute__ ((visibility("default"))) my_exception : public std::exception { virtual void do_throw() const; virtual void do_throw_unknown() const; }; boost_visibility.cpp0000644001066300001450000000030211431060314014356 0ustar jjonesusers#include "boost_visibility.hpp" void my_exception::do_throw() const { boost::throw_exception(*this); } void my_exception::do_throw_unknown() const { throw boost::unknown_exception(); } boost_visibility_main.cpp0000644001066300001450000000157511431060331015376 0ustar jjonesusers#include "boost_visibility.hpp" #include template void result(bool pass) { std::cout << (pass ? "passed: " : "FAILED: ") << typeid(T).name() << std::endl; } template void do_throw() { try { my_exception().do_throw(); } catch (const T&) { result(true); } catch (...) { result(false); } } template void do_throw_unknown() { try { my_exception().do_throw_unknown(); } catch (const T&) { result(true); } catch (...) { result(false); } } int main() { do_throw(); do_throw(); do_throw(); do_throw(); do_throw_unknown(); do_throw_unknown(); do_throw_unknown(); do_throw_unknown(); }