Thursday October 05, 2006
New Google project - Search public source code. And if you use Firefox you can install search plugin.
Permalink
Comments [0]
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.