With regards to Multiple pch files

Guys,

Simply put, Does Clang support multiple PCH’s? How can this be taken advantage of? I have been doing some research regarding the use of Multiple PCH files when building a Pre-compiled header. I was hoping to get some clarification with regards to this issue. Imagine a scenario where I want to build a Specific PCH for a specific Scenario. For example one PCH could be specific to a number of functions, and the other would address specific features attributed to a specific characteristic of an item.

This particular statement caught my attention in one of the discussion boards (https://bugzilla.mozilla.org/show_bug.cgi?id=347592):

Clang does support multiple PCH’s per cpp file (the dependency graph can be

either a list or a DAG). Given that the vast majority of developers are on

Linux or Mac, I’d be quite happy with a solution which required clang.

I would appreciate some clarification on this topic. Thanks a lot in advance.

Oludemilade Mujib Raji: Oludemilade.m.raji@intel.com

Graphics Software Engineer, Intel

1900 Prairie City road

Folsom, CA 95630

Work: (916)-356-0351

Hi,

Clang can support chained PCHs, for example:

if you have the same order of these header includes:

#include <header1.h>

#include <header2.h>

#include <more.h>

You can create a PCH file for header1.h, and a chained PCH for header2.h:

PCH1 (header1.h)
  >
PCH2 (header2.h)
  >
<code>

You can create and chain different PCH files:

PCH1 (header1.h)
  >
PCH3 (header3.h)
  >
<code>

but you cannot mix them, the chained PCH must only be used with the original PCH that it was built with.

There is no DAG configuration for PCHs that is supported, I think the DAG comment may confuse PCHs with the module files system in clang: http://clang.llvm.org/docs/Modules.html
If you are interested in clang modules I’d recommend asking in cfe-dev on how to utilize them, cfe-dev has more traffic than cfe-users.