gcc -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);
}

 

proj/src ડિરેક્ટરી શામેલ કર્યા વિના myfile.c બનાવો :

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

 

શામેલ ડિરેક્ટરી proj/src સાથે myfile.c બનાવો :

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

 


આ પણ જુઓ

Advertising

જીસીસી
°• CmtoInchesConvert.com •°