This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libobjc/50003] -[Protocol respondsTo:] does not work with Clang
- From: "nicola at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 09 Oct 2011 10:47:11 +0000
- Subject: [Bug libobjc/50003] -[Protocol respondsTo:] does not work with Clang
- Auto-submitted: auto-generated
- References: <bug-50003-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50003
Nicola Pero <nicola at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |WORKSFORME
--- Comment #1 from Nicola Pero <nicola at gcc dot gnu.org> 2011-10-09 10:47:11 UTC ---
With GCC trunk (pre-4.7.0), the code reported can't be used because it's using
the Traditional Objective-C runtime API and not the Modern one.
The right implementation with the Modern API is:
+ (BOOL)conformsToProtocol: (Protocol*)protocol
{
Class c;
for (c = self; c != Nil; c = class_getSuperclass (c))
if (class_conformsToProtocol (c, protocol))
return YES;
return NO;
}
I tested this with both GCC and clang, and it seems to work fine with both.
Thanks