[cfe-dev] Instance variables in implementation error?

David Chisnall csdavec at swan.ac.uk
Sun Jul 3 15:43:37 PDT 2011

On 3 Jul 2011, at 22:33, Marcel Weiher wrote:

> I am working on a code-base that for various reasons has instance variables declared in both the @interface and the @implementation section

How old is this codebase?  That was never allowed in Objective-C 4: GCC just accepts it to ease migration of legacy Objective-C 3.3 code (yes, Objective-C 2.0 is the one that comes after Objective-C 4.  Blame Apple marketing for that one).  Since Objective-C 4 was released about 20 years ago, that's expected to be long enough for most people to update their code...

If you're on Darwin, then 64-bit mode is enabling the non-fragile ABI implicitly.  This means that defining instance variables in @implementation contexts actually does define new instance variables.

Can you not simply delete them from the @implementation?  They aren't actually doing anything there - GCC and clang with the fragile ABI will not accept definitions of new ivars there, because without the non-fragile ABI class layouts had to be public so that each class new where its superclass's ivars were.


More information about the cfe-dev mailing list