我正在尝试在我的 C++ 代码中使用wait()
和。fork()
但我在编译阶段收到以下错误
../test/my_test.cpp: In member function 'void MYClass::myMethod()':
../test/my_test.cpp:98: error: no matching function for call to 'wait::wait(int*)'
/data/backfire/staging_dir/toolchain-i386_gcc-4.1.2_uClibc-0.9.30.1/lib/gcc/i486-openwrt-linux-uclibc/4.1.2/../../../../i486-openwrt-linux-uclibc/sys-include/bits/waitstatus.h:68: note: candidates are: wait::wait()
/data/backfire/staging_dir/toolchain-i386_gcc-4.1.2_uClibc-0.9.30.1/lib/gcc/i486-openwrt-linux-uclibc/4.1.2/../../../../i486-openwrt-linux-uclibc/sys-include/bits/waitstatus.h:68: note: wait::wait(const wait&)
代码:
void MYClass::myMethod()
{
pid_t pid;
int status;
if ((pid = fork()) < 0) {
printf("error fork\n");
return;
}
if (pid == 0) {
/* cild*/
......
}
/*parent*/
while (wait(&status) != pid);
}
如何修复错误?