Default include directories

Ian Lance Taylor iant@google.com
Thu Mar 28 17:17:00 GMT 2013


On Thu, Mar 28, 2013 at 8:35 AM, Miguel Guedes
<miguel.a.guedes@gmail.com> wrote:
>
> In order to find out what the system include directories are, I can run
> `cpp -v </dev/null' or compile a test program with GCC (i.e. gcc -v
> test.c). This works fine but unfortunately I'm in need of a programmatic
> way of finding out what the system include directories are without
> resorting to launching external programs.
>
> Anyone knows how GCC determines the directories?

They are constructed at the time that GCC is compiled, based on the
configure option.  They are also affected by any -B option, the
INCLUDE_PATH environment variable, options like -nostdinc, and
obviously options like -I, -iquote, --sysroot, etc.  So really
computing the set of directories is pretty hard, and I would recommend
invoking gcc -v and parsing the output.

Ian



More information about the Gcc-help mailing list