precompiled headers and -I- resp. iquote
Ralf Wildenhues
Ralf.Wildenhues@gmx.de
Wed Jan 19 12:17:00 GMT 2005
* Daniel Jacobowitz wrote on Wed, Jan 19, 2005 at 04:02:06AM CET:
> On Tue, Jan 18, 2005 at 05:58:52PM -0800, Mike Stump wrote:
> > On Jan 18, 2005, at 3:05 PM, Ralf Wildenhues wrote:
> > >cc -H -I.libs bar.c
> > >. foo.h
> > >
> > >cc -H -I.libs -I- bar.c
> > >cc1: note: obsolete option -I- used, please use -iquote instead
> > >! .libs/foo.h.gch/nopic
> > >
> > >>? I am sure I am missing something trivial and obvious, but I just
> > >>don't know what it is.
> > >
> > >Oh, that might just be me. But in your example above, gcc does not
> > >make
> > >use of the precompiled headers.
> >
> > Ah... Curious...
> >
> > mkdir foo.h.gch
> > cc foo.h -o foo.h.gch/nopic
> > cc -fPIC foo.h -o foo.h.gch/pic
> >
> > cc bar.c
Surely that works, thanks. It breaks VPATH builds, though (unless
I resort to -I- again). Note that I neither want to require nor
forbid VPATH builds.
> > ? If you put the headers that you want to compile in include/, you can
> > also avoid this problem I think.
Yes, this is a valid approach. It requires a specific source code
layout from the user, though. One which, IMVHO makes not too much
sense to always enforce, and which INSHO should clearly be documented
in gcc docs. (Side note: documentation did not even reveal the
feature that you could put several versions into a foo.h.gch
directory and have gcc pick an appropriate one by itself).
> Or, put a directory earlier on the search path which includes
> foo.h.gch and touch foo.h in that directory.
I don't think that's a valid option. I would really like to exploit
the fact that gcc will skip the pch if it is not valid for use.
Then the fake empty foo.h will cause unnecessary build failures
(Yes, I can probably make that work by fiddling with #include_next.
But that still does not work without -I-, if the original foo.h
and bar.c reside within the same directory.)
Right now the best way I see is to put them in
$builddir/${sub}foo.h.gch/$output.$postfix
with $output possibly user-specified , $postfix libtool-specified,
$builddir=., $sub a possible subdir-objects path, and:
- require the user (or Automake, eventually) to add
-I$builddir/$sub
- require all use of #include "foo.h" in source files from different
directories.
This is all about how much flexibility I have to take away from
the user. The last requirement is one I don't understand.
Even allowing only the current directory `.' to be inserted before
all others (i.e., before the C source file directory) would be
a significant step forward.
Regards,
Ralf
More information about the Gcc
mailing list