title: Objective-C #import loop
body: <p>I have the following code:</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  #import "ServerRequest.h" // works even though this line is included
  #import "ServerResponseRecord.h"
  
  @protocol ServerRequestDelegate&lt;NSObject&gt;
  
  -(void)request:(id)request gotResponseRecord:(ServerResponseRecord*)response;
  -(void)request:(id)request gotError:(NSError*)error;
  
  @end
  </code></pre>
  
  <p>It compiles and runs fine. However, if I replace the method declarations with:</p>
  
  <pre><code>-(void)request:(ServerRequest*)request gotResponseRecord:(ServerResponseRecord*)response;
  -(void)request:(ServerRequest*)request gotError:(NSError*)error;
  </code></pre>
  
  <p>I get the unexpected syntax error "error: expected ')' before 'ServerRequest'". The only reason I can think this might be a problem is that ServerRequestDelegate.h and ServerRequest.h #import each other. However, I don't understand why the code works with the #import line with (id)request. I also don't understand why it's a syntax error.</p>
  
  <p>Can someone provide a good explanation?</p>