main.m
1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#import <Foundation/Foundation.h>
@interface HasBitfield : NSObject {
@public
unsigned field1 : 1;
unsigned field2 : 1;
};
-(id)init;
@end
@implementation HasBitfield
-(id)init {
self = [super init];
field1 = 0;
field2 = 1;
return self;
}
@end
@interface ContainsAHasBitfield : NSObject {
@public
HasBitfield *hb;
};
-(id)init;
@end
@implementation ContainsAHasBitfield
-(id)init {
self = [super init];
hb = [[HasBitfield alloc] init];
return self;
}
@end
@interface HasBitfield2 : NSObject {
@public
unsigned int x;
unsigned field1 : 15;
unsigned field2 : 4;
unsigned field3 : 4;
}
@end
@implementation HasBitfield2
- (id)init {
return (self = [super init]);
}
@end
int main(int argc, const char * argv[]) {
ContainsAHasBitfield *chb = [[ContainsAHasBitfield alloc] init];
HasBitfield2 *hb2 = [[HasBitfield2 alloc] init];
hb2->x = 100;
hb2->field1 = 10;
hb2->field2 = 3;
hb2->field3 = 4;
return 0; // break here
}