2

I am getting error when trying to import .mm file to another one. Its build like that :

first class FailedMenuLayer is .mm and have in its .h :

#import "gameScene.h"

second class gameScene is .mm, and have in its .h :

#import "FailedMenuLayer.h"
   FailedMenuLayer *menuGO; //here i get the error: unknown type FailedMenuLayer .

why is that ?

Curnelious
  • 1
  • 16
  • 76
  • 150
  • 1
    Please post your full code, it is impossible to guess from just these 3 lines. In particular `FailedMenuLayer.h`. – Guillaume Algis Jun 18 '13 at 09:28
  • my full code is 20000 lines in these classes, and it is not relevant to the specific problem.. its only these lines that cause the error. – Curnelious Jun 18 '13 at 09:39
  • it is relevant, there is definitely a problem with your `FailedMenuLayer` type definition. I'm not asking you to post your 20k loc, all I'm saying is that we can just guess what the problem is based on these 3 lines. – Guillaume Algis Jun 18 '13 at 09:44
  • You have 20,000 lines in `FailedMenuLayer.h`? – trojanfoe Jun 18 '13 at 10:06
  • Check if there is a cycle in headers inclusion. refer:http://stackoverflow.com/questions/7897268/xcode-unknown-type-name – Swetha Jun 18 '13 at 10:52
  • You're not importing a .mm file in the above, you are importing .h files. Your error is probably due to circular references in your .h files. (BTW, you should always use leading upper-case names for classes, and leading lower-case for variables/methods/properties.) – Hot Licks Jun 18 '13 at 11:00

2 Answers2

2

It looks like an import cycle.

One way to fix it is to move the "gameScene.h" import to the .mm file. It's actually a good practice to keep the imports in the .h file limited only to what you actually need in the header and keep everything else in the .mm file.

If you need the import in the header try using @class instead of #import;

@class gameScene;

Don't forget to import gameScene.h in the .mm file also.

SinzianaG
  • 176
  • 6
0

you are not importing ".mm" file, you are importing it's header.

Check your build phases> compile sources for your .mm file to be listed there. That might be your issue

Nikita P
  • 4,226
  • 5
  • 31
  • 55