title: Strange compiler warning C: warning: ‘struct’ declared inside parameter list
body: <p>I just found a quirk in C that I find really confusing. In C it's possible to use a pointer to a struct before it has been declared. This is a very useful feature that makes sense because the declaration is irrelevant when you're just dealing with a pointer to it. I just found one corner case where this is (surprisingly) not true, though, and I can't really explain why. To me it looks like a mistake in the language design.</p>
  
  <p>Take this code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  #include &lt;stdlib.h&gt;
  
  
  typedef void (*a)(struct lol* etc);
  
  void a2(struct lol* etc) {
  
  }
  
  int main(void) {
          return 0;
  }
  </code></pre>
  
  <p>Gives:</p>
  
  <pre><code>foo.c:6:26: warning: ‘struct lol’ declared inside parameter list [enabled by default]
  foo.c:6:26: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]
  foo.c:8:16: warning: ‘struct lol’ declared inside parameter list [enabled by default]
  </code></pre>
  
  <p>To remove this problem we can simply do this:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  #include &lt;stdlib.h&gt;
  
  struct lol* wut;
  
  typedef void (*a)(struct lol* etc);
  
  void a2(struct lol* etc) {
  
  }
  
  int main(void) {
          return 0;
  }
  </code></pre>
  
  <p>The unexplainable problem is now gone for an unexplainable reason. Why? </p>
  
  <p>Note that this question is about the behavior of language C (or possible the compiler behavior of gcc and clang) and not the specific example I pasted.</p>
  
  <p>EDIT:</p>
  
  <p>I won't accept "the order of declaration is important" as an answer unless you also explain why C would warn about using a struct pointer for the first time in a function argument list but allow it in any other context. Why would that possibly be a problem?</p>