我在包含一个包含 sys/type.h
的头文件时遇到了问题。当我使用 g++
或 gcc filename.cpp
编译时,它总是显示错误:sys/type.h,没有这样的文件或目录
.非常困惑。有人可以帮助我吗?
#include<stdio.h>
#include<sys/type.h>
#include<unistd.h>
int main()
{
pid_t child_pid;
printf("the main program ID is %d\n", (int)getpid());
child_pid = fork();
if (child_pid != 0) {
printf("This is the parent process, with id %d\n",
(int)getpid());
printf("the child's process ID is %d\n", (int)child_pid);
} else {
printf("this is the child process, with id %d\n",
(int)getpid());
}
}
最佳答案
应该是<sys/types.h>
带有's'
关于c++ - C/C++ 中某些头文件中的 sys/type.h,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10858583/