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

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

  1. jejlmd macrumors newbie

    Jul 11, 2008
    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??

  2. kpua macrumors 6502

    Jul 25, 2006
    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

    Nov 10, 2006
    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

    Jul 29, 2003
    Silicon Valley
    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

    Jan 5, 2009
    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