2012-06-01 21 views
3

我遇到了一個包含頭文件的問題,該頭文件有sys/type.h。當我使用g++gcc filename.cpp進行編譯時,它總是顯示錯誤:sys/type.h, no such a file or directory。很困惑。有人能幫我嗎?C/C++的某些頭文件中的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()); 
     } 
} 

回答

5

它應該是<sys/types.h>有一個 's'

+0

哈哈,是我不好......我忘了,謝謝! – user1177245