내 질문에 간략한 버전 :부스트 : 스레드가 충돌 함 Microsoft C++ 컴파일러
이 코드는 컴파일러를 충돌시킵니다.
pThread[0] = new boost::thread(
boost::bind(
&cGridAnimator::DoJob, // member function
this), // instance of class
0); // job number
이 코드를 컴파일 할 때 컴파일러가 충돌합니다. (이 코드를 실행할 때 나는 내 프로그램이 아닙니다!)
무엇을 고쳐야합니까? 8 코어 시스템을 활용하기 위해 질문
내가 8 개 별도의 작업에 큰 3D 그리드에서 일을 분할하고의
롱 버전은 별도의 스레드에서 실행된다.
이 완벽하게 작동합니다 :
JOB_LOOP {
pThread[kjob] = new boost::thread(::DoJob, kjob);
}
글로벌 무료 함수 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'.
를 CL.EXE하지 않습니다 "? 내부 컴파일러 오류를보고합니까? –
여기서 "컴파일러가 작동하지 않습니다"라는 메시지가 표시되지 않습니다. 심지어 컴파일러 오류가 표시되지 않습니다! C++ 컴파일러의 경고 2 개와'vcbuild'의 오류 만 있으면됩니다. 나는 당신이 1)/W4로 컴파일하고, 2) 당신의'.vcproj' 파일에 약간의 에러가 있다고 의심한다. 프로젝트 파일을 보여주십시오. 'cGridAnimator :: DoJob()'의 서명도 도움이 될 것입니다. –
그 부분에 당신이 맞아. ICE는 대개 빌드 로그에 인쇄되고 응용 프로그램 충돌은 보통 errorlevel = 1 ... Dumb me가되지 않습니다. – gimpf