Visual C++ 2008 提升问题

Posted

技术标签:

【中文标题】Visual C++ 2008 提升问题【英文标题】:Visual C++ 2008 Boost Problem 【发布时间】:2009-07-27 12:26:21 【问题描述】:

嘿,我正在使用 C++ 通信服务框架,它使用 Boost 的线程库。

我正在编译他们的一个测试项目 (CSF),但我遇到了一个巨大的错误

错误位于文件 bind/mem_fn_template.hpp

中的 Boost Bind 库中

编辑:我通过 BoostPro 提供的 Boost 安装程序安装了 Boost

这里有几个错误

C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(146) : error C2332: 'class' : missing tag name
        C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(193) : see reference to class template instantiation 'boost::_mfi::mf1<R,T,A1>' being compiled
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(146) : error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(146) : error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(146) : error C2988: unrecognizable template declaration/definition
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(146) : error C2059: syntax error : 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(151) : error C2332: 'class' : missing tag name
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(151) : error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(151) : error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(151) : error C2988: unrecognizable template declaration/definition
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(151) : error C2059: syntax error : 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(210) : error C2332: 'class' : missing tag name
        C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(243) : see reference to class template instantiation 'boost::_mfi::cmf1<R,T,A1>' being compiled
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(210) : error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(210) : error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(210) : error C2988: unrecognizable template declaration/definition
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(210) : error C2059: syntax error : 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(215) : error C2332: 'class' : missing tag name
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(215) : error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(215) : error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(215) : error C2988: unrecognizable template declaration/definition
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(215) : error C2059: syntax error : 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(258) : error C2332: 'class' : missing tag name
        C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(305) : see reference to class template instantiation 'boost::_mfi::mf2<R,T,A1,A2>' being compiled
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(258) : error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(258) : error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(258) : error C2988: unrecognizable template declaration/definition
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(258) : error C2059: syntax error : 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(263) : error C2332: 'class' : missing tag name
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(263) : error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(263) : error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(263) : error C2988: unrecognizable template declaration/definition
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(263) : error C2059: syntax error : 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(320) : error C2332: 'class' : missing tag name
        C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(353) : see reference to class template instantiation 'boost::_mfi::cmf2<R,T,A1,A2>' being compiled
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(320) : error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(320) : error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(320) : error C2988: unrecognizable template declaration/definition
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(320) : error C2059: syntax error : 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(325) : error C2332: 'class' : missing tag name
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(325) : error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(325) : error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(325) : error C2988: unrecognizable template declaration/definition
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(325) : error C2059: syntax error : 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(368) : error C2332: 'class' : missing tag name
        C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(415) : see reference to class template instantiation 'boost::_mfi::mf3<R,T,A1,A2,A3>' being compiled
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(368) : error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(368) : error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(368) : error C2988: unrecognizable template declaration/definition
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(368) : error C2059: syntax error : 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(373) : error C2332: 'class' : missing tag name
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(373) : error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(373) : error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(373) : error C2988: unrecognizable template declaration/definition
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(373) : error C2059: syntax error : 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(430) : error C2332: 'class' : missing tag name
        C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(463) : see reference to class template instantiation 'boost::_mfi::cmf3<R,T,A1,A2,A3>' being compiled
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(430) : error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(430) : error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(430) : error C2988: unrecognizable template declaration/definition
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(430) : error C2059: syntax error : 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(435) : error C2332: 'class' : missing tag name
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(435) : error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(435) : error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(435) : error C2988: unrecognizable template declaration/definition
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(435) : error C2059: syntax error : 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(478) : error C2332: 'class' : missing tag name
        C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(525) : see reference to class template instantiation 'boost::_mfi::mf4<R,T,A1,A2,A3,A4>' being compiled
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(478) : error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(478) : error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(478) : error C2988: unrecognizable template declaration/definition
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(478) : error C2059: syntax error : 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(483) : error C2332: 'class' : missing tag name
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(483) : error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(483) : error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(483) : error C2988: unrecognizable template declaration/definition
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(483) : error C2059: syntax error : 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(540) : error C2332: 'class' : missing tag name
        C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(573) : see reference to class template instantiation 'boost::_mfi::cmf4<R,T,A1,A2,A3,A4>' being compiled
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(540) : error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(540) : error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(540) : error C2988: unrecognizable template declaration/definition
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(540) : error C2059: syntax error : 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(545) : error C2332: 'class' : missing tag name
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(545) : error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(545) : error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(545) : error C2988: unrecognizable template declaration/definition
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(545) : error C2059: syntax error : 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(588) : error C2332: 'class' : missing tag name
        C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(635) : see reference to class template instantiation 'boost::_mfi::mf5<R,T,A1,A2,A3,A4,A5>' being compiled
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(588) : error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(588) : error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(588) : error C2988: unrecognizable template declaration/definition
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(588) : error C2059: syntax error : 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(593) : error C2332: 'class' : missing tag name
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(593) : error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(593) : error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(593) : error C2988: unrecognizable template declaration/definition
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(593) : error C2059: syntax error : 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(650) : error C2332: 'class' : missing tag name
        C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(683) : see reference to class template instantiation 'boost::_mfi::cmf5<R,T,A1,A2,A3,A4,A5>' being compiled
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(650) : error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(650) : error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(650) : error C2988: unrecognizable template declaration/definition
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(650) : error C2059: syntax error : 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(655) : error C2332: 'class' : missing tag name
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(655) : error C2993: '' : illegal type for non-type template parameter '<unnamed-tag>'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(655) : error C2143: syntax error : missing ',' before 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(655) : error C2988: unrecognizable template declaration/definition
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(655) : error C2059: syntax error : 'constant'
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(698) : error C2332: 'class' : missing tag name
        C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(745) : see reference to class template instantiation 'boost::_mfi::mf6<R,T,A1,A2,A3,A4,A5,A6>' being compiled
C:\Program Files\boost\boost_1_39\boost/bind/mem_fn_template.hpp(698) : fatal error C1003: error count exceeds 100; stopping compilation

【问题讨论】:

【参考方案1】:

违规行是

template<class U, class B1> R call(U & u, T const *, B1 & b1) const

您确定没有任何名为UB1 的宏吗?您可能可以搜索所有来源以查找“#define U”和“#define B1”。

【讨论】:

只有回想起来才明显!我在使用不同的 Boost 库时遇到了同样的错误,实际上,在我的项目代码的其他地方,模板参数标记(在 Boost 库中,虽然我现在看到这无关紧要)是通过宏定义的。【参考方案2】:

C++ 通信服务框架自 2005 年以来一直没有更新,而 Boost::Thread 从那时起就经常更新,因此可能是某些更改破坏了向后兼容性。我建议尝试 Boost 1.33 看看它是否会给出相同的错误。

【讨论】:

以上是关于Visual C++ 2008 提升问题的主要内容,如果未能解决你的问题,请参考以下文章

Visual.Basic.2008高级编程(第5版)pdf

从 Visual C++ 6 迁移到 Visual C++ 2008 express

将 C++ 项目从 Visual Studio 2008 转换为 Visual Studio 2010

我可以在 Visual Studio 2008 中使用 Visual Studio 6 编译的 C++ 静态库吗?

(工作效率提升杂记) —— Visual Studio 效率提升类的的工具和设置(个人)

(工作效率提升杂记) —— Visual Studio 效率提升类的的工具和设置(个人)