我无法编译这个简单的示例(在 VS 2008 上):
#include <boost/interprocess/sync/named_condition.hpp>
#include <boost/thread/mutex.hpp>
#include <string>
int main(int argc, const char* argv)
{
boost::interprocess::named_condition cond(boost::interprocess::create_only, "somd.notify");
boost::mutex the_mutex;
while (true)
{
const boost::system_time timeout = boost::get_system_time() + boost::posix_time::milliseconds(500);
boost::mutex::scoped_lock lock(the_mutex);
if (cond.timed_wait(lock, timeout))
{
// Do something useful
}
}
return 0;
}
我得到的编译错误是(boost v1.38.0):
1>....\boost/interprocess/sync/named_condition.hpp(326) : error C2273: 'function-style cast' : illegal as right side of '->' operator
1> ..\src\main.cpp(13) : see reference to function template instantiation 'bool boost::interprocess::named_condition::timed_wait<boost::mutex::scoped_lock>(L &,const boost::posix_time::ptime &)' being compiled
1> with
1> [
1> L=boost::mutex::scoped_lock
1> ]
想法?