agraja.wordpress.com

GCC Include Files Path

In C, Linux on September 7, 2007 at 5:26 am

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
  1. visit us!
    newsbox.cc
    newsbox.us
    nbstatus.wordpress.com
    NOW!