[cfe-dev] PTH for C++

Ted Kremenek kremenek at apple.com
Mon Jun 28 15:08:41 PDT 2010


PTH should work fine for C++, since it only works on C++.

The usage of PTH/PCH follows the same mechanism for precompiled headers as gcc:

$ clang -x c++-header t.h -o t.h.pth

$ clang -include t.h t.cpp

Clang will automatically use 't.h.pth' if it is present instead of t.h.

On Jun 28, 2010, at 2:52 PM, Reid Kleckner wrote:

> Hey folks,
> 
> I wanted to ask about the existing PTH support in clang, and how well
> it works for C++.
> 
> I couldn't find any user facing documentation, but my understanding is
> that you use it by picking some representative C++ file that includes
> most of the headers you want to pre-tokenize and invoke clang like so:
> clang -cc1 -emit-pth most_headers.h -o most_headers.h.pth
> 
> Then you do the rest of your compiles with -token-cache most_headers.h.pth:
> clang -cc1 -token-cache most_headers.h.pth foo.cc -o foo.o
> 
> Is this correct?  If so, how would I go about modifying a standard
> Makefile setup to use PTH?  I don't see how this functionality is
> exposed through the driver.
> 
> Have other people had success with PTH?  I remember ddunbar mentioned
> in passing on IRC that PTH doesn't work well for C++, but I'm looking
> for more detail.  If no one has numbers for how it performs, I was
> going to self-host clang using PTH to make some.
> 
> Thanks,
> Reid
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev





More information about the cfe-dev mailing list