title: Can't figure out 'warning: incompatible Objective-C types'
body: <p>I have a subclass of NSObject that implements an <code>-(id)initWithRootElement:(MyElement *)e</code> method.  NSXMLDocument has an identical method that takes an NSXMLElement.  When I compile, I get the following warning:</p>
  
  <p><code>warning: incompatible Objective-C types 'struct MyElement *', expected 'struct NSXMLElement *' when passing argument 1 of 'initWithRootElement:' from distinct Objective-C type</code></p>
  
  <p>In this case, I'm compiling with Clang + LLVM on SnowLeopard with Xcode 3.2.1, but this also happens with GCC 4.2 on both Leopard and SnowLeopard.</p>
  
  <p>What I don't understand is why it's throwing a warning for my direct NSObject subclass when NSXMLDocument has to inherit from NSXMLNode first?  Shouldn't it know that <code>-(id)initWithRootElement:(NSXMLElement *)e</code> only applies to NSXMLDocument which has nothing to do with my class?  I could understand if I was trying to overload the method, but I'm not.  Please tell me I'm not going crazy...</p>
  
  <pre><code>#import &lt;Foundation/NSAutoreleasePool.h&gt;
  #import &lt;Foundation/NSXMLElement.h&gt;
  // Importing this here causes the warning...
  // #import &lt;Foundation/NSXMLDocument.h&gt;
  
  typedef NSObject MyElement;
  
  @interface TestClass : NSObject
  {
  }
  
  - (id)initWithRootElement:(MyElement *)element;
  @end
  
  @implementation TestClass
  - (id)initWithRootElement:(MyElement *)element { return nil; }
  @end
  
  // ...but here it doesn't
  // #import &lt;Foundation/NSXMLDocument.h&gt;
  
  int main (int argc, const char * argv[])
  {
      NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
  
      // No warning! Inheritance: NSXMLDocument -&gt; NSXMLNode -&gt; NSObject
      NSXMLElement *xmlElement = [[NSXMLElement alloc] initWithName:@"foo"];
      [[TestClass alloc] initWithRootElement:xmlElement];
  
      // warning: incompatible Objective-C types 'struct MyElement *', expected 'struct NSXMLElement *' when passing argument 1 of 'initWithRootElement:' from distinct Objective-C type
      MyElement *element = [[MyElement alloc] init];
      [[TestClass alloc] initWithRootElement:element];
  
      [pool drain];
      return 0;
  }
  </code></pre>