이 작품 :는 표준을 구축 :: 스레드 기능
std::thread t = std::thread(printf, "%d", 1);
이 작동하지 않습니다 :
t2 = std::thread(my_thread_func , std::ref(context));
또는
std::thread t1 = std::thread(my_thread_func , context_add);
my_thread_func 정의 :
int my_thread_func(long long *context_add)
을 ,451,515,
상황은 .. 일부 구조체 내가
오류 '참조 패스'를 할 노력하고있어 :
function call missing argument list;
error C2661: 'std::thread::thread' : no overloaded function takes 2 arguments
>>> 편집 혼란을 < < <
죄송합니다. .. 실제로 MainPage의 public 내에서 my_thread_func를 정의하고 있습니다. 따라서 native 타입을 사용할 수 없기 때문에 오랫동안 시도해 볼 가치가 있다고 생각했습니다.
/* test data types, context for thread function, in .cpp (not in namespace) */
typedef struct _test_context
{
HANDLE hHandle;
unsigned int flag;
}test_context_t;
test_context_t *context;
//Do something with its member
context_add = (long long *)context;
std::thread t2 = std::thread(sem_waiting_thread, context_add);
ERROR : 지금 ..이 간단한 궁금
namespace App1
{
public ref class MainPage sealed
{
public:
MainPage();
public:
MainPage();
int my_thread_func(long long cotext);
..
};
}
< < < < 편집 2 >>> : 같은
error C3867: 'App1::MainPage::my_thread_func': function call missing argument list; use '&App1::MainPage::my_thread_func' to create a pointer to member
error C2661: 'std::thread::thread' : no overloaded function takes 2 arguments
내 네임 스페이스 보인다 또한 작동하지 않습니다!
void f1(int n)
{
for(int i=0; i<5; ++i) {
// Print n
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
.
.
.
int n=0;
std::thread t2(f1, n+1); (//This didn't work,same error!)
.
.
.
but this worked!
std::thread t2;
.
.
.
t2= std::thread (f1, n+1);
여기에서 시도 : http://en.cppreference.com/w/cpp/thread/thread/thread
문제는 조금 혼란 .. .* 문맥은 struct *이지만, 선언문에서'long long'에 대한 포인터입니다 ... 함수의 실제 선언과 전달할 타입을 게시 할 수 있습니까? –
작동하지 않는 std :: thread 생성자 행을 주석으로 처리하고 컴파일하는 완전한 예제를 보여 주어야합니다. 그러면 누군가가 그 선을 올바르게 쓰는 법을 보여 줄 수 있습니다. 그렇지 않으면 추측해야합니다. 즉, 나는 betabandido가이 경우에 성공적으로 대답 할 수 있었다고 생각하지만, 우리 대부분은 그와 마찬가지로 심령이 아닙니다. – abarnert
"네이티브 형식을 사용할 수 없습니까?" 왜'문맥'을 '길다란 길'에 던져 넣는거야? – betabandido