public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc include search order
@ 2008-08-07  4:02 Simon, Jb
  2008-08-07 16:30 ` Eljay Love-Jensen
  0 siblings, 1 reply; 2+ messages in thread
From: Simon, Jb @ 2008-08-07  4:02 UTC (permalink / raw)
  To: gcc-help


Hi.
In my unit testing I need to change some header files (target is
vxWorks, which supports some things that the sun does not). 
So, what I do is fetch the development tree, and then in a new unit test
directory I attempt to compile the unit under test. Since this is NOT
vxworks, I use sed to change some of the .h files and put them in a
./changed directory.

When I try to compile the file, it is still using the .h file from the
original location, even though I have listed the include path for
./changed before the include path for the development tree.

Here is a partial output from gcc using the -v option

GNU CPP version 3.1 (cpplib) (sparc ELF)
GNU C++ version 3.1 (sparc-sun-solaris2.8)
        compiled by GNU C version 3.1.
ignoring nonexistent directory "NONE/include"
#include "..." search starts here:
#include <...> search starts here:
 .
 changed
 /export/home4/xxx/yyyy/builds/int_rel5_latest/src/mp/interface
 /export/home4/xxx/yyyy/builds/int_rel5_latest/src/ap/app
 /export/home4/xxx/yyyy/builds/int_rel5_latest/src/shared/common
 /export/home4/xxx/yyyy/builds/int_rel5_latest/src/shared/interface
 /usr/local/include/g++-v3
 /usr/local/include/g++-v3/sparc-sun-solaris2.8
 /usr/local/include/g++-v3/backward
 /usr/local/include
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.1/include
 /usr/local/sparc-sun-solaris2.8/include
 /usr/include
End of search list.

I know the changed file is correct and that the include is not working
as expected, because when I copy the file from ./changed, back into the
development tree, the compilation works as expected.

One more bit of information. The source that I cam compiling is in
/export/home4/xxx/yyyy/builds/int_rel5_latest/src/ap/app
And it is including files from
/export/home4/xxx/yyyy/builds/int_rel5_latest/src/shared/common
These include files should be including the files from ./changed (when
they exist) but they are ignoring the .h files in the ./changed
directory and are instead using other, unchanged files in the
/export/home4/xxx/yyyy/builds/int_rel5_latest/src/shared/common
directory.

The gcc command line is something like

  TEST_DIR="."
  
  CHANGED_DIR_NAME=changed
  CHANGED_FILES_DIR=${TEST_DIR}/${CHANGED_DIR_NAME}

  CICU_HEADER_FILES="-I ${AP_INTERFACE_FILES} -I ${AP_APP_FILES} -I
${SHARED_COMMON_FILES} -I ${SHARED_INTERFACE_FILES}"
  
  HEADERS="-I ./ -I ${CHANGED_FILES_DIR} ${CICU_HEADER_FILES}"
  DEFINES="-DSUNRUN -DA10_DEBUG -DJOETEST"
  
  CFLAGS="-v -c -g -O1 -pipe -Wformat -Wunused -Wuninitialized -Wshadow
-Wmissing-prototypes -Wmissing-declarations"
  
  printf "Compiling the UUT File\n"
  gcc -fprofile-arcs -ftest-coverage ${CFLAGS} ${HEADERS} ${DEFINES}
${AP_APP_FILES}/unitUnderTest.cpp 


I hope this explanation is clear. If anyone knows how to fix the command
line so that it gets the .h files in the "changed" directory are used
instead of files in the other include directories.

Thanks
Joe

----------------------------------------------------
Time Flies like an Arrow. Fruit Flies like a Banana
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: gcc include search order
  2008-08-07  4:02 gcc include search order Simon, Jb
@ 2008-08-07 16:30 ` Eljay Love-Jensen
  0 siblings, 0 replies; 2+ messages in thread
From: Eljay Love-Jensen @ 2008-08-07 16:30 UTC (permalink / raw)
  To: Simon, Jb, GCC-help

Hi Joe,

Does GCC 3.1 support the -iquote switch?

If so, -iquote./changed *may* be a way to put a different directory at a
higher priority than the same directory as the source file.  (Maybe.  I've
never attempted this trick.)

Does GCC 3.1 support the -I- switch?

If it does, that's another way you could put -I./changed ahead of -I. in the
include path.

man gcc
Look for -iquote
Look for -I-

HTH,
--Eljay

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-08-07  4:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-07  4:02 gcc include search order Simon, Jb
2008-08-07 16:30 ` Eljay Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).