ObjC in gcc 4: warning about [SomeClass class]
ObjC in gcc 4: warning about [SomeClass class]
- Subject: ObjC in gcc 4: warning about [SomeClass class]
- From: Thomas Lachand-Robert <email@hidden>
- Date: Sun, 1 May 2005 17:28:02 +0200
Hi all,
The new objective-C compiler in GCC 4 is more nitty-picky about
incorrect constructions, and I think it's a good thing in general. (I
actually found a heck of missing [super dealloc]...)
But here is a problem which is difficult to solve for me, and is in
some sense a bug INMHO. I have two classes SomeClass and
SomeOtherClass which are loosely related. In fact, the only link
between them is that SomeOtherClass requires SomeClass to be inited
before creating any instance. So I coded my implementation as follows:
@class SomeClass;
@implementation SomeOtherClass
+(void) initialize {
[SomeClass class]; // make sure this class is inited
}
Note that I don't want to import SomeClass.h, because it's heavy and
absolutely not necessary.
Ok, this works with gcc 3, but gcc 4 issues a warning
"SomeClass may not respond to +class"
For ordinary objects, I would cast to (id) or (Class), but this is
not possible here since SomeClass is not an object, but a class name.
(This would yield a parse error.) I don't know a simple way to tell
the compiler that the class actually inherits from NSObject, so there
is no problem here.
For me all Objective C classes actually respond to +class, because it
is exactly the standard way to convert their name but I'm unsure if
this is really a requirement of the language.
So do you think it's a bug? And can you suggest a workaround?
Thanks,
Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet à la chose. >> Molière, Tartuffe.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden