gcc -I opcija zastavice

gcc -Dodajem uključuju direktorij datoteka zaglavlja.

Sintaksa

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

Primjer

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

 

Izgradite myfile.c bez uključivanja direktorija proj / src :

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

 

Izgradite myfile.c pomoću direktorija za uključivanje proj / src :

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

 


Vidi također

Advertising

OUU
BRZE TABLICE