GCC Include Files Path

GCC looks in several different places for headers.

On a normal Unix system, if you do not instruct it otherwise, it will look for headers requested with #include <file> in:

/usr/local/include
libdir/gcc/target/version/include
/usr/target/include
/usr/include
You can add to this list with the -Idir command line option.

Below is a small demo

///////////     defines.c   ////////
#include <stdio.h>
#include <defines.h>
int main()
begin
    printf("hellon");
    return 0;
end

This requires the folowing header file

///////     headers/defines.h   ///////////
#define begin {
#define end }
//////  save this file in directory named headers

Compile defines.c as below

[raja@AGRAJA ~] gcc defines.c -Iheaders
Advertisements

3 thoughts on “GCC Include Files Path

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s