GCC's order of header file search path

View: New views
3 Messages — Rating Filter:   Alert me  

GCC's order of header file search path

by Jeffi Edward.J :: Rate this Message:

| View Threaded | Show Only this Message


Hi,

I have a doubt in gcc's order of header file search path.

The application, which I'm porting (Diab compiler to GCC compiler), has standard header files (with modification) from different vendors.

The makefile uses -I option to include those headers(although GCC suggests to use -isystem to specify vendor-supplied include paths). Diab C compiler always searches standard include paths before -I paths.

I read in GCC manual that path given by -I will be searched first prior to the standard include path. So I'm getting lot of unnecessary errors.

I tried to include GCC standard include path with -I option prior to remaining vendor specific -I paths. But GCC cleverly ignores the path which is standard system include directory.

I want GCC to always search standard header path first prior to -I option.

Is there any option to make GCC to behave so? Or Have I missed any option in GCC configuration while building?

Re: GCC's order of header file search path

by Ian Lance Taylor-3 :: Rate this Message:

| View Threaded | Show Only this Message

"Jeffi Edward.J" <j.jeffi@...> writes:

> Diab C compiler
> always searches standard include paths before -I paths.

It does?  That seems odd.

> I read in GCC manual that path given by -I will be searched first prior to
> the standard include path. So I'm getting lot of unnecessary errors.
>
> I tried to include GCC standard include path with -I option prior to
> remaining vendor specific -I paths. But GCC cleverly ignores the path which
> is standard system include directory.
>
> I want GCC to always search standard header path first prior to -I option.
>
> Is there any option to make GCC to behave so? Or Have I missed any option in
> GCC configuration while building?

There is no gcc option to tell it to search the standard include
directories before any of the -I option.

I'm not aware that gcc does anything clever about ignoring a patch for
the system include directory.  If it does do that, perhaps you can
avoid it by using -nostdinc.

Ian

Re: GCC's order of header file search path

by Jeffi Edward.J :: Rate this Message:

| View Threaded | Show Only this Message


Sorry. Diab C behaves in the same way as GCC.
The problem which I faced is different. Sorry for the confusion.

Ian Lance Taylor-3 wrote:
"Jeffi Edward.J" <j.jeffi@yahoo.co.in> writes:

> Diab C compiler
> always searches standard include paths before -I paths.

It does?  That seems odd.

> I read in GCC manual that path given by -I will be searched first prior to
> the standard include path. So I'm getting lot of unnecessary errors.
>
> I tried to include GCC standard include path with -I option prior to
> remaining vendor specific -I paths. But GCC cleverly ignores the path which
> is standard system include directory.
>
> I want GCC to always search standard header path first prior to -I option.
>
> Is there any option to make GCC to behave so? Or Have I missed any option in
> GCC configuration while building?

There is no gcc option to tell it to search the standard include
directories before any of the -I option.

I'm not aware that gcc does anything clever about ignoring a patch for
the system include directory.  If it does do that, perhaps you can
avoid it by using -nostdinc.

Ian