I'm trying to use boost::thread but I can't compile because of an error compiling locks.hpp. I'm using Boost 1.47.0 from BoostPro (precompiled for Windows). (I've been coding for many years, and I've just hit one of those thangs that has me stumped.)
Adding the following include to my code causes the error:
#include "boost/thread.hpp"
The error:
开发者_Python百科
1>boost/thread/locks.hpp(85): error C2958: the left parenthesis '(' found at 'boost\thread\locks.hpp(85)' was not matched correctly
1> boost/thread/locks.hpp(91) : see reference to class template instantiation 'boost::detail::has_member_lock<T,true>' being compiled
1>boost/thread/locks.hpp(85): error C2988: unrecognizable template declaration/definition
1>boost/thread/locks.hpp(85): error C2059: syntax error : '<end Parse>'
1>boost/thread/locks.hpp(85): error C2238: unexpected token(s) preceding ';'
1>boost/thread/locks.hpp(109): error C2958: the left parenthesis '(' found at 'boost\thread\locks.hpp(109)' was not matched correctly
1> boost/thread/locks.hpp(115) : see reference to class template instantiation 'boost::detail::has_member_unlock<T,true>' being compiled
1>boost/thread/locks.hpp(109): error C2988: unrecognizable template declaration/definition
1>boost/thread/locks.hpp(109): error C2059: syntax error : '<end Parse>'
1>boost/thread/locks.hpp(109): error C2238: unexpected token(s) preceding ';'
Lines 84 and 85 of locks.hpp:
template< typename U,typename V>
static true_type has_member(V (U::*)());
Lines 108 and 109 of locks.hpp:
template<typename U,typename V>
static true_type has_member(V (U::*)());
I've looked for preprocessor defines to mask out the code, but nothing (yet) works.
So it seems that the '*' is giving the compiler some trouble.
Any suggestions/help much appreciated
Something that its included before locks.hpp is defining V
as a macro. Just before including locks.hpp add #undef V
. That's not the solution though, the solution is to find who is being such a bad player defining a macro named V
(at least is all uppercase) and removing it. If applicable, perhaps even file a bug report against such library.
精彩评论