1 msgcross compiler building
2 msgx86_64-pc-mingw32
1 msgComparison failure Comiling 4.2 svn on RedHat EL-3
1 msgRe: Compilation Error on AIX 5.3 with g++ 3.3.2
2 msgg77 question.
1 msgBasic blocks and profiling information
3 msgVariadic macros and commas
1 msgBuilding cross compiler
2 msgMissing file in GCC build
4 msgbetter load/store scheduling
9 msgIs there a free substitute for Flexilint?
4 msgHow to pass function names as parameter?
1 msgwhat is the exact nature of special treatment t...
4 msgglibc-2.5 compilation failing

Adding include directories (-I)
\ Sebastian Biallas (28 Feb 2007)
. \ John Love-Jensen (28 Feb 2007)
. . \ Sebastian Biallas (28 Feb 2007)
. . . \ Ian Lance Taylor (28 Feb 2007)
. . . . \ Sebastian Biallas (28 Feb 2007)
. . . . . \ Ian Lance Taylor (28 Feb 2007)
. . . . . . \ Sebastian Biallas (28 Feb 2007)
. . . \ John Love-Jensen (28 Feb 2007)
. . . . \ Sebastian Biallas (28 Feb 2007)
. . . . . \ John Love-Jensen (28 Feb 2007)
. . . . . . \ Sebastian Biallas (28 Feb 2007)
. . . . . . . \ John Love-Jensen (28 Feb 2007)

2 msglanguages supported by gcc-3.x
3 msgbuilding gcc cross compiler
1 msgbuilding gcc-3.x cross compiler
3 msgcannot exec cpp0
3 msgLinker problems: dependencies with .a file not ...
Subject:Adding include directories (-I)
Group:Gcc-help
From:Sebastian Biallas
Date:28 Feb 2007


Hello,

Consider the following file structure of some project:

/src
/dir1
file1.c
header1.h
/dir2
header2.h

My question is: What is the correct/preferred way to #include
"header2.h" in file1.c?


1. Add something like -I($topdir) to the Makefile
-------------------------------------------------

This is what I usually do. That way I can write #include
"dir2/header2.h" in file1.c. This is, AFAICS, what automake does.

Now, what I just learned, the -I switch does not only modify the search
list for #include "" but also for #include <>. This was completely new
to me (what's that good for?) and yields to a problem:

I have a file called src/process.h. And now, when I include <unistd.h>
under cygwin, <unistd.h> includes <process.h> which results in inclusion
of my "process.h" which is totaly wrong at this place.

I'm not sure if the cygwin folks messed this up or if this is my fault
(don't name files process.h? Don't use -I?)

2. Add something like -I- first
-------------------------------

Uh, this sounds like a rather obscure switch. Even more, since it
changed it syntax recently to -iquote.

3. Don't use -I at all
----------------------

I could use #include "../header2.h" in file1.c. But I don't think that
this is the preferred method for this really common problem.


Thanks in advance,
Sebastian


© 2004-2008 readlist.com