title: How much do forward declarations affect compile time?
body: <p>I am very interested in some studies or empirical data that shows a comparison of compilation times between two c++ projects that are the same except one uses forward declarations where possible and the other uses none.</p>
  
  <p>How drastically can forward declarations change compilation time as compared to full includes?</p>
  
  <pre><code>#include "myClass.h"
  </code></pre>
  
  <p>vs.</p>
  
  <pre><code>class myClass;
  </code></pre>
  
  <p><strong>Are there any studies that examine this?</strong></p>
  
  <p>I realize that this is a vague question that greatly depends on the project. I don't expect a hard number for an answer. Rather, I'm hoping someone may be able to direct me to a study about this.</p>
  
  <p>The project I'm specifically worried about has about 1200 files. Each cpp on average has 5 headers included. Each header has on average 5 headers included. This regresses about 4 levels deep. It would seem that for each cpp compiled, around 300 headers must be opened and parsed, some many times. (There are many duplicates in the include tree.) There are guards, but the files are still opened.  Each cpp is separately compiled with gcc, so there's no header caching.</p>
  
  <p>To be sure no one misunderstands, I certainly advocate using forward declarations where possible. My employer, however, has banned them. I'm trying to argue against that position.</p>
  
  <p>Thank you for any information.</p>