tags:

views:

89

answers:

1

Hi!

I have a class named MyClass. And in the file MyClass.m I start the coding with this line:
extern MyClass *gMyClass;

and I got this error:

error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token

What's the problem? What do you think?

A: 

Make sure MyClass is declared before the extern statement. Are you importing MyClass.h before you declare extern MyClass *gMyClass?

Also, it seems a bit odd that the gMyClass global is declared extern in the class's .m file. Usually, the extern MyClass *gMyClass statement is either put in the header, or you make the *gMyClass static and allow access to it through class methods in your MyClass class.

dreamlax