علم خيار دول مجلس التعاون الخليجي -I

تضيف gcc -I تشمل دليل ملفات الرأس.

بناء الجملة

$ gcc -Idir [options] [source files] [object files] [-o output file]

مثال

proj / src / myheader.h:

// myheader.h
#define NUM1 5

 

myfile.c:

// myfile.c
#include <stdio.h>
#include "myheader.h"
 
void main()
{
    int num = NUM1;
    printf("num=%d\n", num);
}

 

قم ببناء myfile.c بدون تضمين دليل proj / src :

$ gcc myfile.c -o myfile
myfile.c:2:22: fatal error: myheader.h: No such file or directory
compilation terminated.
$

 

بناء myfile.c مع include directory proj / src :

$ gcc -Iproj/src myfile.c -o myfile
$ ./myfile
num=5
$

 


أنظر أيضا

Advertising

مجلس التعاون الخليجي
° • CmtoInchesConvert.com • °