This is the mail archive of the
mailing list for the GCC project.
objc/7836: problem casting id as id<protocol>
- From: pauljohn at ku dot edu
- To: gcc-gnats at gcc dot gnu dot org
- Date: 5 Sep 2002 13:19:54 -0000
- Subject: objc/7836: problem casting id as id<protocol>
- Reply-to: pauljohn at ku dot edu
>Synopsis: problem casting id as id<protocol>
>Arrival-Date: Thu Sep 05 06:26:01 PDT 2002
>Originator: Paul E. Johnson
GNU/Linux, gcc 3.1/3.2
The Swarm libraries (www.swarm.org) compile with gcc-3.0, but with gcc-3.1/3.2, we get some new warnings about protocols.
We have plenty of places where we cast ids as (id <whatever_protocol>) and when the thing we cast does not actually implement all the methods in the protocol, then the compiler warns us about it. In the 3.0 gcc,
we did not get warnings. If we use the flag -Wno-error instead of -Werror, then the build of Swarm libraries finishes and programs that
run with the libraries work.
Consider this method:
- setProbe: (id <Probe>)theProbe
myProbe = (id <MessageProbe>) theProbe;
The compiler warns that "warning: object does not conform to the `MessageProbe' protocol". It no longer trusts us to make the cast the way we wnat it. Its warning is correct, "theProbe" does not conform.
But we don't want the warning. We have the compiler set to treat warnings as errors.
Try compiling the Swarm libraries! If you want to try, I'd suggest on of the development snaps, for example: