Boost logo

Boost :

From: Harling, Torsten (THarling_at_[hidden])
Date: 2006-07-26 06:07:40


Hello,

I have a little problem regarding boost and ACE cooperation.
ACE is an C++ class library, providing many functions for
platform independency.

I have also reported this to the debian team, and will also
try to contact the ACE developers:

Package: libboost-dev
Version: 1.32.0-6
Package: libace-dev
Version: 5.4.2.1.0-4

Consider the following program boostfirst.cpp:
------------------------------------------------------------
#include <boost/shared_ptr.hpp>
#include <ace/OS.h>
#include <iostream>

using namespace std;

int main (int argc, char **argv)
{
    cout << "sizeof (boost::detail::sp_counted_base) == "
        << sizeof (boost::detail::sp_counted_base) << endl;
}
------------------------------------------------------------

Compile and run with:

$ g++ boostfirst.cpp -o boostfirst -lstd
$ ./boostfirst
sizeof (boost::detail::sp_counted_base) == 12

Now try including the ace header first (only the order of
the include files is changed):
------------------------------------------------------------
#include <ace/OS.h>
#include <boost/shared_ptr.hpp>
#include <iostream>

using namespace std;

int main (int argc, char **argv)
{
    cout << "sizeof (boost::detail::sp_counted_base) == "
        << sizeof (boost::detail::sp_counted_base) << endl;
}
------------------------------------------------------------

The output of the second program is:
sizeof (boost::detail::sp_counted_base) == 36

A great difference. The reason for this is, that the
#include <ace/OS.h> somehow defines _REENTRANT, which
triggers the boost library to include a mutex in
sp_counted_base. I think, the order of the includes
should not matter. Therefore, either '#include <ace/OS.h>'
should not define _REENTRANT, or the boost headers
should ignore it.

I found out, that adding the -pthread option to the
g++ command also avoids this bug.

Im using Debian sarge 3.1, g++ 3.3.5-3, libc6 2.3.2.ds1-22sarge3
and libace-dev 5.4.2.1.0-4.

Regards,
Torsten


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk