Take the 2-minute tour ×

I have the following Objective-C headers:

// Menu.h

#import <UIKit/UIKit.h>
#import "GameController.h"

@interface Menu : UIImageView {
    GameController *gameController;   // "Expected specifier-qualifier-list
                                      // before GameController"

- (void)appear;



// GameController.h

#import <UIKit/UIKit.h>
#import "Menu.h"

@interface GameController : UIView {
    Menu *menu;                       // "Unknown type name 'Menu'"

- (void)startLevel0;
- (void)startLevel1;
- (void)startLevel2;


When I try to build the project, Xcode (v4) yells at me, saying Expected specifier-qualifier-list before GameController and unknown type name 'Menu'. I'm sure that they are somehow related, but I have no idea how?

share|improve this question

2 Answers 2

It's not good practice to have mutually-including header files. Instead of importing Menu.h, use the @class directive. Try removing #import "Menu.h" and adding @class Menu in its place. Ditto for Menu.h (remove GameController include, and add the @class directive)

share|improve this answer
It worked! Thank you. –  aniiye Feb 23 '11 at 17:03

You have a circular reference in your imports. The compiler builds a dependency tree from the import statements so when two Classes rely on each other it doesn't know how to compile one before the other.

Sadly, gcc kicks out a fairly nonsensical error statement when this happens "Expected specifier-qualifier-list". @yan is correct that you should use the @class directive. Check out this question for a solid explanation: @class vs. #import

share|improve this answer

Your Answer


