title: forward declaration of typedefed structs
body: <p>In C often structs are typedefed to avoid writing struct everywhere.</p>
  
  <p>When using this names as opaque pointer parameters in headers you have to forward declare them. It is rather annoying that the whole typedef has to be duplicated. </p>
  
  <p>Example:</p>
  
  <p>some header defines some types:</p>
  
  <pre><code>typedef struct sBlaBlaFooBar{
   int someData;
  }BlaBlaFooBar;
  </code></pre>
  
  <p>Some other header uses this structure as pointer parameter. But to avoid huge include dependencies BlaBlaFooBar.h should not be included and just a forward declaration is used.</p>
  
  <p>So you have to write <code>typedef struct sBlaBlaFooBar BlaBlaFooBar;</code> to forward declare it.</p>
  
  <p>That does bother me is the redundancy that i have to know the tag name of the structure because normally it does not matter. And if it is changed, all the forward declarations also have to be changed even if the typename is the same.</p>
  
  <p>Is there some smart way around this?</p>
  
  <p><br>
  more detailed explanation:<br></p>
  
  <ul>
  <li>a lot of headers with structure definitions (that may be also composed structures (just to show deep dependency graphs))
  <ul>
  <li>s1.h</li>
  <li>s2.h</li>
  <li>s3.h </li>
  <li>s4.h</li>
  </ul></li>
  <li>a BlaBlaFooBar header with a <code>BlaBlaFooBar</code> structure that is a composite of all these.</li>
  <li>Additional structures BlaBlaBarFoo with similar topology (from other sub structures)</li>
  <li>then modules that defines new structures <code>NewStruct</code> and functions <code>NewStruct_create(NewStruct* out, const BlaBlaFooBar* in);</code> that processes 
  the above structures as input. These headers only need the typedefs and only the implementation has to know about exact <code>BlaBlaFooBar</code> structure definitions.</li>
  <li>Addional modules that only work on <code>NewStruct</code> and to not necessarily have to be recompiled if <code>BlaBlaFooBar</code> changes.</li>
  </ul>
  
  <p>So to avoid these kind of dependencies the structures have to be forward declared in the header and the c-file includes the definition.</p>