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?
Make sure
MyClassis declared before theexternstatement. Are you importingMyClass.hbefore you declareextern MyClass *gMyClass?Also, it seems a bit odd that the
gMyClassglobal is declaredexternin the class’s.mfile. Usually, theextern MyClass *gMyClassstatement is either put in the header, or you make the*gMyClassstatic and allow access to it through class methods in yourMyClassclass.