jam*_*ick 1 c++ multithreading pthreads void
好的,我试图在c ++中的另一个线程中运行一个函数.它不需要参数,它是一个void函数.所以当我看到这个警告说:
warning: function declared 'noreturn' should not
return [-Winvalid-noreturn]
Run Code Online (Sandbox Code Playgroud)
我很惊讶.我正在使用pthread作为我的主题.这是我的功能声明:
void* checkLogKext(void*);
Run Code Online (Sandbox Code Playgroud)
这是我调用我的函数的地方:
pthread_t t1;
pthread_create(&t1, NULL, &checkLogKext, NULL);
Run Code Online (Sandbox Code Playgroud)
这是我的功能:
void* checkLogKext(void*) {
ifstream logKext("/LogKextUninstall.command");
if (logKext.is_open()) {
// Do something
}
}
Run Code Online (Sandbox Code Playgroud)
你的退货类型是void*你不想要退货的void.关于你为你的功能所采取的论点,也可以这样说.
void* foo(void*) // this takes a void* as paremeter and is expected to return one too
void foo(void) // doesn't return anything, and doesn't take any parameters either
| 归档时间: |
|
| 查看次数: |
891 次 |
| 最近记录: |