<div class="gmail_quote">On Sat, Apr 4, 2009 at 2:04 AM, Robert Purves <span dir="ltr"><<a href="mailto:listrp@gmail.com">listrp@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
2. The command  clang test.h  produces the expected file test.h.gch.<br>
Is this file recognised and used automatically in subsequent<br>
compilations containing #include "test.h" (as gcc does), or is it<br>
necessary to add the option -include-pth=test.h.gch?</blockquote><div><br></div><div>Yes, the driver will automatically look for this file when it sees a -include option. If it finds it, it will automatically use the -include-pth option to clang-cc.</div>
<div>--</div><div><div>ddunbar@ozzy:tmp$ touch t.h</div><div>ddunbar@ozzy:tmp$ touch t.c</div><div>ddunbar@ozzy:tmp$ clang t.h</div><div>ddunbar@ozzy:tmp$ ls</div><div>t.c<span class="Apple-tab-span" style="white-space:pre">      </span>t.h<span class="Apple-tab-span" style="white-space:pre"> </span>t.h.gch</div>
<div>ddunbar@ozzy:tmp$ clang -### -include t.h t.h</div><div>clang version 1.0 (<a href="https://ddunbar">https://ddunbar</a>@<a href="http://llvm.org/svn/llvm-project/cfe/trunk">llvm.org/svn/llvm-project/cfe/trunk</a> 68413:68417M)</div>
<div>Target: i386-apple-darwin10</div><div> "/Volumes/Data/ddunbar/llvm/Debug/bin/clang-cc" "-triple" "i386-apple-darwin10" "-emit-pth" "-disable-free" "--relocation-model" "pic" "--disable-fp-elim" "--unwind-tables=0" "--fmath-errno=0" "-mmacosx-version-min=10.6.0" "-include-pth" "t.h.gch" "-o" "t.h.gch" "-x" "c-header" "t.h"e</div>
<div>--</div><div><br></div><div>The design was chosen so that 'clang' could be dropped into a build system that already uses gcc PCH files, and things would "just work". In the long term we can do a lot more with PTH...</div>
<div><br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
3. -include-pth hates to have the '=' omitted:<br>
$ clang -c test.c -o test.o -include-pth=test.h.gch<br>
$ clang -c test.c -o test.o -include-pth test.h.gch<br>
clang: warning: test.h.gch: 'linker' input file unused when '-c' is<br>
present<br>
error: PTH file -o could not be read<br>
<br>
Is this inscrutable error a bug, or By Design?</blockquote><div><br></div><div>-include-pth is not intended to be used directly.</div><div><br></div><div> - Daniel</div><div> </div></div>