user1177245
user1177245

Reputation: 119

sys/type.h in some head files in C/C++

I met a problem with including a header file which has sys/type.h. When I compile using g++ or gcc filename.cpp it always show me the error: sys/type.h, no such a file or directory. very confused. Can someone help me?

#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());
        }
}

Upvotes: 4

Views: 5138

Answers (1)

Jonathan Wakely
Jonathan Wakely

Reputation: 171263

It should be <sys/types.h> with an 's'

Upvotes: 6

Related Questions