Asking gcc for the include directory location?

Kai Ruottu karuottu@mbnet.fi
Thu Dec 7 09:35:00 GMT 2006


Toralf Lund wrote:
> Is there any way I can get gcc to tell me where the "normal" include 
> directory is located?

 No, AFAIK  The 'gcc' is only the "compiler driver" and so doesn't need 
or handle headers
at all...  The clue is in the question: "Which part of GCC needs and 
handles the headers?"

> I mean, for my system's native compiler, this directory is 
> "/usr/include", while on e.g. my arm-coff cross-gcc, it's 
> "/usr/arm-coff/include". Is there any way to ask the compilers to 
> print out these values? If not, how about the full "built-in" include 
> path?

 There seems to be no "standard" way for this.  Especially for C++ etc.  
Anyway when understanding
that it is the C preprocessor, 'cpp', which needs headers, trying it 
instead of 'gcc', should give something :

   arm-coff-cpp -v

Like :

kai@Dell:~> cpp-arm-coff-3.2 -v
Reading specs from /usr/local/lib/gcc-lib/arm-coff/3.2.3/specs
Thread model: single
gcc version 3.2.3 (by karuottu@mbnet.fi)
 /usr/local/lib/gcc-lib/arm-coff/3.2.3/cpp0 -lang-c -v -D__NO_INLINE__ 
-D__STDC_HOSTED__=1 -Acpu=arm -Amachine=arm -D__ARM_ARCH_3__ 
-D__APCS_32__ -D__ARMEL__ -D__semi__ -D__arm__ -
GNU CPP version 3.2.3 (cpplib) (ARM/coff)
ignoring nonexistent directory "NONE/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/lib/gcc-lib/arm-coff/3.2.3/include
 /usr/local/arm-coff/sys-include
 /usr/local/arm-coff/include
End of search list.

But only for C :-(   Older GCCs before gcc-3.3 accepted options like 
'-lang-c++' for their "real" C preprocessor
and a command like :

   arm-coff-cpp -Wp,-v,-lang-c++

would have given also the C++ search paths, for instance :

kai@Dell:~> cpp-arm-coff-3.2 -Wp,-v,-lang-c++
GNU CPP version 3.2.3 (cpplib) (ARM/coff)
ignoring nonexistent directory "NONE/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/c++/3.2.3
 /usr/local/include/c++/3.2.3/arm-coff
 /usr/local/include/c++/3.2.3/backward
 /usr/local/include
 /usr/local/lib/gcc-lib/arm-coff/3.2.3/include
 /usr/local/arm-coff/sys-include
 /usr/local/arm-coff/include
End of search list.

After gcc-3.3 the "real C preprocessor" was included in the "real 
compilers" like 'cc1'
and 'cc1plus', so running them with some options would tell the headers 
search paths.
But how to run them without knowing where they are?   One way is to use 
the 'gcc'
option '-print-prog-name=cc1' or '-print-prog-name=cc1plus', for instance :

kai@Dell:~> `gcc-arm-coff-3.3 -print-prog-name=cc1plus` -v
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/c++/3.3.4
 /usr/local/include/c++/3.3.4/arm-coff
 /usr/local/include/c++/3.3.4/backward
 /usr/local/include
 /usr/local/lib/gcc-lib/arm-coff/3.3.4/include
 /usr/local/arm-coff/sys-include
 /usr/local/arm-coff/include
End of search list.

with "command substitution", asking 'gcc' to tell the full name of 
'cc1plus' and then use it
with the '-v' option...

Toying with 'cc1', 'cc1plus' etc. using '--help' could reveal other 
possibilities....  But as was
seen, there isn't any "standard" for this.  That 'cpp' remains inside 
'cc1*' can though be quite
expected and so using 'cc1*' directly should always work...



--
For unsubscribe information see http://sourceware.org/lists.html#faq



More information about the crossgcc mailing list