Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7843235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:30:18+00:00 2026-06-02T16:30:18+00:00

I am working on an iPhone game using the cocos2d framework, and recently encountered

  • 0

I am working on an iPhone game using the cocos2d framework, and recently encountered a problem I can’t seem to solve. After adding a new class to my project and doing some work in it, I tried to compile my code and several of the classes I hadn’t even touched broke. It seems like those classes just forgot how import external classes. I am getting the error up there in several of my classes, but here is one example:

#import "cocos2d.h"
#import "XZombie.h"
#import "WayPoint.h"
#import "XBuilding.h"

//@class XBuilding;

@interface Hoarde : CCNode
{
    float _spawnRate;
    int _totalXombies;
    NSMutableArray *_path;
    XBuilding *_target;
    NSMutableArray *_zombies;
    bool _zombiesReset;
}

@property (nonatomic) float spawnRate;
@property (nonatomic) int totalXombies;
@property (nonatomic, retain) NSMutableArray *path;
@property (nonatomic, retain) XBuilding *target;
@property (nonatomic, retain) NSMutableArray *zombies;
@property (nonatomic, assign) bool zombiesReset;

- (id) initWithZombieCount:(int)totalXombies Target:(XBuilding *) target SpawnRate:(float)spawnrate;
- (void) resetZombies;

@end

I get the error on the line that reads XBuilding *_target;
If I uncomment the @class XBuilding;, the error goes away, so while that doesn’t really solve my problem, it gives me a tool to work around it.


If I do the @class trick for all the files I am having a problem with, I can work around that. The thing is, I get a new – but similar – error besides the specifier-qualifier-list one. Some lines of code give me Expected a ')' before *token or Expected a ';' before *token. Those lines usually gave me the previous error as well, so the @class trick worked as well, but I haven’t the slightest idea why this stuff is doing what it’s doing. I read somewhere (the cocos2d forums, I think) that renaming the .m files to .mm might do the trick, but it didn’t for me.

So, while I can continue working on my project, I would really like to know how on Earth to avoid stuff like that in the future…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:30:19+00:00Added an answer on June 2, 2026 at 4:30 pm

    Please check whether there is circular dependency, for example, importing ClassB.h in ClassA.h and vice versa. This is the typical scenario where “Expected specifier-qualifier-list before…” error occurs.

    I suggest to use only @class in your headers files except:

    • #importing the super class
    • #importing the protocols your class implements

    The header files should be #imported in your implementation files.

    “The Objective-C Programming Language” says:

    The @class directive minimizes the amount of code seen by the compiler and linker, and is therefore the simplest way to give a forward declaration of a class name. Being simple, it avoids potential problems that may come with importing files that import still other files. For example, if one class declares a statically typed instance variable of another class, and their two interface files import each other, neither class may compile correctly.

    More reference:

    • @class vs. #import
    • http://www.iphonedevsdk.com/forum/iphone-sdk-development/54417-expected-specifier-qualifier-list-before-xxxappdelegate-error.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anybody help me to solve this problem. I am working on iphone development.
Hey all Im working on a game for iphone using cocos2d and sdk 4.1
I am working on iPhone racing car game development using cocos3d.In this how can
I am working on a 2D iPhone game using OpenGL ES and I keep
I'm trying to add animations to my game (iPhone app, using cocos2d). The game
I'm working on a game for the iPhone using flash, and since memory is
I'm new to Objective C and XCode, currently working on my first iPhone Game.
I'm working on a game for iPhone which creates a path after your character
I'm working on an iPhone game that takes place on the ocean surface. Can
I am working on iPhone game application, in which user can play game and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.