[cfe-dev] @encode objc problem

Jean-Daniel Dupas devlists at shadowlab.org
Sat Mar 7 12:37:00 PST 2009


Done: #3752


Le 7 mars 09 à 20:55, Fariborz Jahanian a écrit :

> Behavior should match gcc's.
>
> Please file a bugzilla with a test case.
>
> - fariborz
>
>
>
>
>
> On Mar 7, 2009, at 10:52 AM, Jean-Daniel Dupas wrote:
>
>> Hello,
>>
>> I have a question about the behavior of the @encode compiler  
>> directive
>> in Obj-C.
>>
>> If we where talking about another language the answer would probably
>> be: read the spec, unfortunately, there is not Obj-C spec.
>>
>> From the Objective-C 2.0 Programming Language:
>> 	@encode(type_spec) 	Yields a character string that encodes the type
>> structure of type_spec.
>>
>> http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_950_section_5.html
>>
>>
>> So we could think that the clang implementation is fine, but here  
>> come
>> the bad news.
>>
>> Some widely used testing framework (SenTestingKit which is part of  
>> the
>> Xcode distribution for example) use this kind of test
>>
>> if (@encode(__typeof__(a1)) != @encode(__typeof__(a2))) {
>>
>> }
>>
>> Yep, @encoded "returns" a character string, and these strings are
>> compared using == (or != ) and not strcmp, and it works quite well
>> using GCC because GCC generates only one const string per type.
>>
>> As you want that clang be as much compatible as possible with  
>> 'GCC', I
>> think something should be done about this issue.
>>
>> And if the Obj-C ref is not updated to guarantee that the returns
>> value can be compared using ==, I think you may also add a warning.
>>
>>
>>
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090307/f68f3564/attachment.html>


More information about the cfe-dev mailing list