title: unknown type name C vs C++
body: <p>I tried to create a struct that holds a  pointer to it's type:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  struct test{
      test* t;
  };
   int main(){
      return 0;
   }
  </code></pre>
  
  <p>while compiled with gcc, this code produced an error:</p>
  
  <blockquote>
    <p>:5:2: error: unknown type name 'test'</p>
  </blockquote>
  
  <p>but while compiled on g++ it went just fine.</p>
  
  <p>So what I want to understand is:</p>
  
  <p><strong>1)</strong> What causes this difference? I thought that if gcc uses one-pass compilation and g++ uses multipass that could explain it, but as I understood, this is not true.</p>
  
  <p><strong>2)</strong> How can I avoid this error and define a struct with a pointer to it's own type? (I don't want to use a void* or use casting unless there is no other option)</p>