|
Boost : |
From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2007-09-07 05:12:16
boost/detail/flyweight_mutex.hpp implements a mutex class based on a
Win32 CRITICAL_SECTION or using Pthreads according to the
following pp logic:
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
// based on CRITICAL_SECTION
#elif defined(BOOST_HAS_PTHREADS)
// based on Pthreads
The problem with this is that WIN32 and related macros are not predefined
in some environments (Cygwin at least) but rather they are defined inside
windows.h, thus making the logic above dependent on the inclusion context.
For instance, the two programs
#include <boost/detail/lightweight_mutex.hpp>
#include <iostream>
int main()
{
std::cout<<sizeof(boost::detail::lightweight_mutex)<<std::endl;
}
and
#include <windows.h>
#include <boost/detail/lightweight_mutex.hpp>
#include <iostream>
int main()
{
std::cout<<sizeof(boost::detail::lightweight_mutex)<<std::endl;
}
output 4 and 24, respectively, under Cygwin.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk