gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RFC: Non-fragile ivar implementation


From: David Chisnall
Subject: Re: RFC: Non-fragile ivar implementation
Date: Tue, 19 May 2009 22:50:33 +0100

I forgot to include a little demonstration:

$ cat ivar.m
#import <objc/Object.h>
#include <dlfcn.h>


@interface B : Object
- (void)print;
@end

@interface A : B {
        @public
        int a;
        float b;
}
@end
@implementation A
- (void)print
{
        printf("a is %d\n", a);
        [super print];
}
@end

int main(void)
{
        A *a =[A new];
        a->a = 1;
        [a print];
        return 0;
}
$ cat ivar2.m
#import <objc/Object.h>

@interface B : Object {
        int w;
}
@end
@implementation B
- (void)print
{
        printf("w is %d\n", w);
}
@end

$ clang ivar.m ivar2.m -lobjc -fpic -fobjc-nonfragile-abi -L/opt/gcc/ lib && ./a.out
a is 1
w is 0





reply via email to

[Prev in Thread] Current Thread [Next in Thread]