c++ - C/C++ 中某些头文件中的 sys/type.h

标签 c++ c

我在包含一个包含 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/

相关文章:

c++ - OpenGL GLM矩阵/vector 未正确初始化

c++ - 使用 HDF5 保存要在 C++ 中读取的 MATLAB 结构

c - 在 C 中将 float 转换为处理器内部的 int

c - fscanf 段错误

c++ - c和c++中函数指针转换的区别

c++ - 从 C++ Visual 2006 迁移到 V2010 CFile 到 ifstream

python - 使用 python 和调用函数自省(introspection) C++ dll

c++ - 抑制 C++ 中未使用的变量警告 => 编译器错误或代码错误?

c++ - 用于提高中间浮点计算精度的编译器标志

c++ - 从 C++ 程序构建 C 程序