병렬 분산 처리 parallel_for 함수 사용법이 궁금합니다.
VOID PopupDisplay(HWND& hwnd, RECT& area, COLORREF (*display)[1000]) { parallel_for(area.left, area.right, [](int x) { HDC hdc=GetDC(hwnd); for(int y=area.top;y<=area.bottom;y++) { SetPixel(hdc, x, y, display[x][y]); } ReleaseDC(hwnd, hdc); }); }
------ 빌드 시작: 프로젝트: test16, 구성: Debug Win32 ------
컴파일하고 있습니다...
test16.cpp
c:\documents and settings\the\my documents\visual studio 2008\projects\test16\test16\test16.cpp(126) : error C2146: 구문 오류 : ')'이(가) 'x' 식별자 앞에 없습니다.
c:\documents and settings\the\my documents\visual studio 2008\projects\test16\test16\test16.cpp(126) : error C2065: 'x' : 선언되지 않은 식별자입니다.
c:\documents and settings\the\my documents\visual studio 2008\projects\test16\test16\test16.cpp(126) : error C2143: 구문 오류 : ';'이(가) '{' 앞에 없습니다.
c:\documents and settings\the\my documents\visual studio 2008\projects\test16\test16\test16.cpp(126) : error C3861: 'parallel_for': 식별자를 찾을 수 없습니다.
c:\documents and settings\the\my documents\visual studio 2008\projects\test16\test16\test16.cpp(129) : error C2065: 'x' : 선언되지 않은 식별자입니다.
c:\documents and settings\the\my documents\visual studio 2008\projects\test16\test16\test16.cpp(129) : error C2065: 'x' : 선언되지 않은 식별자입니다.
c:\documents and settings\the\my documents\visual studio 2008\projects\test16\test16\test16.cpp(132) : error C2059: 구문 오류 : ')'
빌드 로그가 "file://c:\Documents and Settings\the\My Documents\Visual Studio 2008\Projects\test16\test16\Debug\BuildLog.htm"에 저장되었습니다.
test16 - 오류: 7개, 경고: 0개
========== 빌드: 성공 0, 실패 1, 최신 0, 생략 0 ==========
위와 같은 구문오류가 출력됩니다. 오류를 어떻게 고쳐야 하나요?
lambda 문법 쓰시는데 C++11을 지원하지 않는
lambda 문법 쓰시는데 C++11을 지원하지 않는 VS2008 쓰시고 계시네요.
lambda가 뭔지는 모르지만, 질문글 함수 안되길래 다른 함수 사용해봤습니다.
질문글에서 사용한 함수가 지원이 안되는 것으로 나옵니다. 그래서 CreateThread 함수를 사용했는데, 이번에는 의도한대로 화면을 가져와 출력하지 못하는군요.
c:\documents and
c:\documents and settings\the\my documents\visual studio 2008\projects\test16\test16\test16.cpp(126) : error C2146: 구문 오류 : ')'이(가) 'x' 식별자 앞에 없습니다.
c:\documents and settings\the\my documents\visual studio 2008\projects\test16\test16\test16.cpp(126) : error C3861: 'parallel_for': 식별자를 찾을 수 없습니다.
에러부터 보세요.
1. 말했듯, lambda 문법은 C++11 이후 부터 지원합니다. 다시 말하면, VS2011 이후 쓰는게 안전하다는 겁니다.
(물론 그 이전 버전도 C++11 feature 부분지원합니다.)
2 식별자 없다는건 헤더파일이 포함되지 않았을 가능성이 큽니다.
만약 헤더파일 포했했는데도 "unresolved external symbol" 뜬다면 링커에게 라이브러리 위치 알려주세요.
http://vsts2010.tistory.com/119
https://msdn.microsoft.com/ko-kr/library/Dd492418.aspx
댓글 달기