Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It is a current weakness of GCC (the implementation).</p> <p>Today, GCC precompiled headers are essentially a memory dump of the compiler's state just after parsing the whole header (PCH uses the Gcc Garbage Collector machinery with <a href="http://gcc.gnu.org/onlinedocs/gccint/Type-Information.html" rel="nofollow">GTY</a> annotations inside the compiler's source and <code>gengtype</code>) So to make it work; basically <em>ggc</em> is copying the entire GCC heap [the data inside the compiler] inside your PCH.</p> <p>For users, it means that the only current way to take profit of PCH is to have exactly one single header (which itself would include several system headers like <code>&lt;stdio.h&gt;</code> in C or <code>&lt;vector&gt;</code> in C++) which is included by all your <code>*.c</code> or <code>*.cc</code> files.</p> <p>When GCC compiles an <code>#include</code> which cannot be satisfied by a PCH (e.g. because it has some code <em>before</em> it), it just ignores that PCH. In your example, it has already parsed some of <code>header.h</code> before attempting to load the PCH, and it notices that its heap is not empty (some "locations", i.e. source file positions, are already inside), so it cannot use the PCH so skips it.</p> <p>Diego Novillo and other people at Google are working to improve that in the <a href="http://gcc.gnu.org/wiki/pph" rel="nofollow">PPH</a> branch of GCC. I have no idea if their work will be mature enough for GCC 4.8</p> <p>BTW, I find absolutely essential the presence of a garbage collector inside a compiler, but I find GCC's GC very poor... (Most GCC contributors disagree with my position).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload