我正在尝试使用boost :: thread,但由于编译locks.hpp时出错而无法编译。我正在使用BoostPro(针对Windows进行预编译)的Boost 1.47.0。 (我已经编码了很多年了,我刚刚遇到了困扰我的那一批。)

在我的代码中添加以下包含会导致错误:

#include "boost/thread.hpp"


错误:
ojit_pre

locks.hpp的第84和85行:

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 ';'


locks.hpp的第108和109行:

    template< typename U,typename V>
    static true_type has_member(V (U::*)());


我一直在寻找预处理器定义来掩盖代码,但是(目前)没有任何效果。

因此,似乎“ *”给编译器带来了麻烦。

任何建议/帮助深表感谢

最佳答案

在locks.hpp之前包含的内容是将V定义为宏。在包含locks.hpp之前,添加#undef V。不过,这不是解决方案,解决方案是找出谁在定义一个名为V的宏(至少全部为大写字母)的情况下成为如此糟糕的玩家并将其删除。如果适用,甚至可以针对此类库提交错误报告。

关于c++ - Boost/thread/locks.hpp(85)编译错误(缺少括号)VS2010,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7749882/

10-12 20:39