Objective-C Error: "redeclared as a different kind of symbol"

Discussion in 'Mac Programming' started by jejlmd, Jul 11, 2008.

  1. jejlmd macrumors newbie

    Joined:
    Jul 11, 2008
    Location:
    Ohio
    #1
    I am desperately trying to learn COCOA, by first learning Objective-C. In Stephen Kochan's book "Programming in Objective-C", I have tried the following code lifting verbatim code from his text, which does run without error, but the following code tutorial produces the error message: 'Point' redeclared as a different kind of symbol:

    #import <stdio.h>

    // ------ @interface section ------

    @interface Point: NSObject
    {
    int pointX;
    int pointY;
    }

    any suggestions anybody??

    Thanks!
     
  2. kpua macrumors 6502

    Joined:
    Jul 25, 2006
    #2
    If you look at the error line that should appear before the one you're looking at, it should tell you where the previous declaration with the same name is.

    Basically, this means that the namespace already has something called "Point" and you can't use it because that would introduce an ambiguity. Rename it to something else. A common practice is to use a two or three letter prefix that will be somewhat unique to your project. For example, Cocoa uses 'NS'.
     
  3. aLoC macrumors 6502a

    Joined:
    Nov 10, 2006
    #3
    Yes, MacTypes.h already defines Point, and may be included at some deep level. Try using a prefix like kpua said.
     
  4. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #4
    For very common object names, I usually use something like "MyPoint" , or for an app or library named foo: "FooPoint" . Makes it easier to search for it without also getting a bunch of foundation and other library's various Point types.
     
  5. a420aDay macrumors newbie

    Joined:
    Jan 5, 2009
    #5
    using XCode??

    I ran into the same error and thanks to the response by aLoC, you can continue on if you rename your class from Point to something thing Coordinates.

    Or go the the file progName_Prefix.pch and make sure you comment out the import of teh Cocoa.h file. If you comment out the loading of the Cocoa framework, you can then use the name "Point" as your class name definition.
     

Share This Page