Why BOOST_HAS_THREADS is not defined

I've got a question on Sun C++ forum why BOOST_HAS_THREADS is not defined explicitly in the sunpro_cc.hpp. The answer can be found just by grep on Boost source code but I decide to put explanation here.

Let's look at the piece of boost/config/suffix.hpp:

#if (defined(__MT__) || defined(_MT) || defined(_REENTRANT) \\
    || defined(_PTHREADS)) && !defined(BOOST_HAS_THREADS)
#  define BOOST_HAS_THREADS
#endif

When you compile multithread application you should use -mt command line option. This option implicitly defines _REENTRANT so Boost defines BOOST_HAS_THREADS automatically. You can check it by hand:

% cat test.cc
#include <boost/thread.hpp>

#ifdef BOOST_HAS_THREADS
#error BOOST_HAS_THREADS is defined
#endif

% CC -mt -I$HOME/storage/boost_1_32_0 -c test.cc
"test.cc", line 4: Error: #error BOOST_HAS_THREADS is defined.
Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

atanasyan

Search

Categories
Archives
« July 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today