Boost logo

Boost Users :

From: Bobby Thomale (bobby-thomale_at_[hidden])
Date: 2002-12-17 10:46:02


It's me again with weird problems compiling Boost on the Mac! :-)

I just converted my MacOS X code from CFM to Mach-O and I ran into another
small compilation problem.

This time, it is the thread code. Now that I am moved over to Mach-O, the
_POSIX_THREADS flag is true, causing posix_features.hpp to set
BOOST_HAS_PTHREADS to true.

This seems to be causing all sorts of compiler errors. Probably due to the
fact that, even though some of the posix headers are being included, I am
using the MSL headers rather than the BSD headers, and my understanding is
that none of that posix stuff will actually work until I eject the MSL in
favor of the Unix C headers, which I am not prepared to do right now.

That and the fact that since I am using Carbon, TARGET_CARBON is also true,
therefore BOOST_HAS_MPTASKS is getting set to true.

So anyway ... BOOST_HAS_PTHREADS and BOOST_HAS_MPTASKS are both getting
defined.

I would like to be able to control whether BOOST_HAS_PTHREADS gets defined,
because I am actually wanting to use the MP libraries instead, despite
_POSIX_THREADS being defined.

It looks like how you handled this same problem with Windows was by adding a
!defined(BOOST_HAS_WINTHREADS) to the condition as follows:

# if defined(_POSIX_THREADS) && (_POSIX_THREADS+0 >= 0) &&
!defined(BOOST_HAS_WINTHREADS)
# define BOOST_HAS_PTHREADS
# endif
 
One solution would be to add an additional check for MP Tasks as follows:

# if defined(_POSIX_THREADS) && (_POSIX_THREADS+0 >= 0) &&
!defined(BOOST_HAS_WINTHREADS) && !defined(BOOST_HAS_MPTASKS)
# define BOOST_HAS_PTHREADS
# endif

I did this in my local working copy and it seems to have fixed the problem.
I had to add an additional "#define BOOST_HAS_MPTASKS" to my user.hpp to
make sure that BOOST_HAS_MPTASKS got defined before the above check.

I am not sure if this is the best way or if there is a better way to solve
this problem.

I suppose another approach would be to check for !defined(TARGET_CARBON) in
the above check - if carbon is on, MP Tasks will get turned on. Or you
could in the place where BOOST_HAS_MPTASKS gets defined, undef the
BOOST_HAS_PTHREADS.

But the way I solved it in my local copy (shown above) using
!defined(BOOST_HAS_MPTASKS) seemed the cleanest to me, especially since it
looks like it is how you solved the same problem for Windows.

Anyway - I tried hard to find a way to make this compile without changing
anything but my user.hpp but I failed. (If someone has any ideas I'd love
to hear them.)

                                -- Bobby

---------------------------------------------------------------------
Bobby Thomale
Senior Software Developer
Inoveon Corporation
http://www.inoveon.com/
---------------------------------------------------------------------


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