rdelfin
rdelfin

Reputation: 816

Expected * before * error (expected specifier-qualifier-list error) in xcode

I have the following code:

@interface Building : GameObject
{
    CGPoint mapSquarePos;
    CGPoint SquareSize;
    bool isBuilding;
    UIImage *BuildingImage;
    Person *garnisonedPerson;  //Error is here
}

i have imported the Person.h file. What could cause this error

Upvotes: 1

Views: 383

Answers (1)

Jesse Black
Jesse Black

Reputation: 7976

Try

@class Person;
@interface Building : GameObject
{
    CGPoint mapSquarePos;
    CGPoint SquareSize;
    bool isBuilding;
    UIImage *BuildingImage;
    Person *garnisonedPerson;  //Error is here
}

and importing Person.h in your implementation file

If that doesn't work, it seems BuildingImage could be a class name.

Update for Rickyman20

@class Person

Tells the compiler that Person is a class. In general I do not import other header files within my header file. An example where I do this is when I use cocos2d.

In that case #import "cocos2d.h in my header file allows the use of the whole cocos2d library within my header without causing a compiler error

Upvotes: 4

Related Questions