Boost logo

Boost Users :

From: Marshall Clow (marshall_at_[hidden])
Date: 2007-12-06 21:14:35


At 5:31 PM +0100 12/6/07, Lothar May wrote:
>Hi,
>
>I still have no idea how to solve this problem. This time I'm using
>the boost patch of the adobe open source library to build boost 1.34.1
>as universal binary according to
>http://opensource.adobe.com/asl_readme.html
>
>A simple program to reproduce the problem is:
>
>--cut here--
>
>#include <iostream>
>#include <boost/filesystem.hpp>
>
>using namespace std;
>using namespace boost::filesystem;
>
>int
>main()
>{
> try
> {
> directory_iterator i("does_not_exist");
> } catch(...)
> {
> cout << "This is never printed on MacOS 10.5." << endl;
> }
> return 0;
>}
>
>--cut here--
>
>Compile and link as follows (on MacOS 10.5):
>
>g++ test.cpp -lboost_filesystem-mt-1_34_1 -o test
>
>Loads of linker warnings will show up (all of them "ld: warning ...
>has different visibility ...").

Except for the "catch ( ... )" not catching it, this sounds like a
problem that gcc has on Mac OS (and probably elsewhere) having to do
with catching exceptions thrown across shared library boundaries.

There's an explanation here
<http://developer.apple.com/technotes/tn2007/tn2185.html>, or you can
search the archives of the "carbon-dev" mailing list at
lists.apple.com for more information.

The basic problem is that when the runtime compares type_info's to
see if a catch block can catch the exception, it compares to see _if
they have the same address_. This fails, of course, if a shared
library and an application each have their own copy of the type_info
structure. Mucking with the visibility of the symbols (your "loads of
linker warnings" ) can fix this.

-- 
-- Marshall
Marshall Clow     Idio Software   <mailto:marshall_at_[hidden]>
It is by caffeine alone I set my mind in motion.
It is by the beans of Java that thoughts acquire speed,
the hands acquire shaking, the shaking becomes a warning.
It is by caffeine alone I set my mind in motion.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net