我的问题的简短版本:boost:线程崩溃微软C++编译器
此代码崩溃了编译器。
pThread[0] = new boost::thread(
boost::bind(
&cGridAnimator::DoJob, // member function
this), // instance of class
0); // job number
尝试编译此代码时,编译器崩溃。 (当我运行这个代码时,这不是我的程序!)
什么需要修复?
问题
我分手了在大型3D网格工作纳入8个单独工作的龙版在单独的线程中运行,以便采取一个8芯机的优势。
这完美的作品:
全球免费功能DoJob从cGridAnimator的全局实例读取数据,根据工作数量。然而,我不喜欢所有这些全局变量的浮动,我不喜欢使用这么多的访问器方法来获取必要的数据。使用cGridAnimator的方法会更加整洁。
因此,代码在这个问题的顶部。
但是,当我在MSVC++ 2008上编译它时,编译器会发出以下抱怨,然后崩溃。
1>Compiling...
1>mfm1.cpp
1>C:\Program Files\boost\boost_1_38_0\boost/bind.hpp(1643) : warning C4180: qualifier applied to function type has no meaning; ignored
1> C:\Program Files\boost\boost_1_38_0\boost/bind.hpp(1677) : see reference to class template instantiation 'boost::_bi::add_cref<Pm,I>' being compiled
1> with
1> [
1> Pm=void (__thiscall cGridAnimator::*)(int),
1> I=1
1> ]
1> .\mfm1.cpp(158) : see reference to class template instantiation 'boost::_bi::dm_result<Pm,A1>' being compiled
1> with
1> [
1> Pm=void (__thiscall cGridAnimator::*)(int),
1> A1=cGridAnimator *
1> ]
1>C:\Program Files\boost\boost_1_38_0\boost/mem_fn.hpp(318) : warning C4180: qualifier applied to function type has no meaning; ignored
1> C:\Program Files\boost\boost_1_38_0\boost/bind/bind_template.hpp(344) : see reference to class template instantiation 'boost::_mfi::dm<R,T>' being compiled
1> with
1> [
1> R=void (int),
1> T=cGridAnimator
1> ]
1>Project : error PRJ0002 : Error result 1 returned from 'C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\cl.exe'.
你所说的“崩溃意思“?报告内部编译器错误? – 2009-08-21 17:08:25
这里我没有看到任何“编译器崩溃”。我甚至没有看到编译器错误!你得到的只有2个来自C++编译器的警告,然后是来自'vcbuild'的错误。我强烈怀疑你1)正在编译/ W4,2)在'.vcproj'文件中有一些错误。请显示项目文件。 'cGridAnimator :: DoJob()'的签名也是有帮助的。 – 2009-08-21 17:19:02
你是对的那部分。一个ICE通常被打印到生成日志,并且应用程序崩溃通常不会导致errorlevel = 1 ...愚蠢的我。 – gimpf 2009-08-21 17:23:16