gcc -I 添加头文件的 include 目录。
$ gcc -Idir [options] [source files] [object files] [-o output file]
proj/src/myheader.h:
// myheader.h
          #define NUM1 5
myfile.c:
// myfile.c   在没有 include 目录 proj/src 的情况下编译 myfile.c: $ gcc myfile.c -o myfile   在有 include 目录 proj/src 的情况下编译 myfile.c: $ gcc -Iproj/src myfile.c -o myfile  
          #include 
          #include "myheader.h"
           
          void main()
          {
              int num = NUM1;
              printf("num=%d\n", num);
          }
        
          myfile.c:2:22: fatal error: myheader.h: No such file or directory
          compilation terminated.
          $
          $ ./myfile
          num=5
          $
        另请参阅
        
      
我们所有内容来源于rapidtables.com,遗憾于其没有中文版本,因此建立中文版供网民使用,所有内容版权属于rapidtables.