On 2 Mar 2010, at 20:31, Truls Becken wrote:

> David Chisnall wrote:
> 
>> On 2 Mar 2010, at 19:54, Truls Becken wrote:
>> 
>>> Smells like a compiler bug, I guess. David?
>> 
>> Clang uses the ObjC 2 rules for protocols; they should either be empty 
>> (forward-declared), in which case they will be resolved at load time, or 
>> their definitions should match.  This is to prevent two modules from 
>> declaring different protocols of the same name and breaking after testing 
>> for protocol conformance.
>> 
>> You should not ever adopt a protocol that is only forward-declared.  This 
>> will break introspection with the old ABI and cause all sorts of irritating 
>> problems.  With the new runtime, if you adopt a forward-declared protocol 
>> then the runtime will try to fix up its definition to match the real 
>> definition one, if it can.
> 
> So this means that old-style declarations:
> 
> @protocol UKTest;
> 
> should be changed to empty definitions:
> 
> @protocol UKTest
> @end
> 
> and not to imports, which create unnecessary work for the compiler:
> 
> #import <UnitKit/UKTest.h>
> 
> Correct?

No, exactly the opposite.  If you are adopting the protocol, you should include 
the CORRECT definition of the protocol, not an incorrect definition (which will 
work for now, but will abort at load time in the future when I decide everyone 
has had enough time to fix their ugly code).  

Using a forward definition will PROBABLY work, but the semantic analysis layer 
will tell you that you are doing something monumentally stupid, and because we 
use -Werror this will prevent the code from compiling.

The correct fix is to #import the UKTest.h header.  Actually, the correct fix 
is to move the test stuff into a category and adopt the protocol there, so we 
don't adopt it at all unless we are building the test suite.

David

-- Sent from my Cray X1
_______________________________________________
Etoile-dev mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-dev

Reply via email to