gcc -I zastavica možnosti

gcc -I dodaja vključuje imenik datotek glave.

Sintaksa

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

Primer

proj/src/myheader.h:

// myheader.h
#define NUM1 5

 

moja datoteka.c:

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

 

Zgradite myfile.c brez vključenega imenika proj/src :

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

 

Zgradite myfile.c z vključenim imenikom proj/src :

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

 


Poglej tudi

Advertising

GCC
°• CmtoInchesConvert.com •°