blob: 16ad5a61482c8e4057c157675d6bc9cef7ec0532 (
plain)
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
|
#include <stdio.h>
struct fields {
unsigned f0 : 3;
unsigned f1 : 5;
signed f2 : 3;
unsigned toto1: 16;
unsigned toto2: 16;
};
unsigned get_toto1(struct fields x) {
return x.toto1;
}
unsigned get_toto2(struct fields x) {
return x.toto2;
}
int get_f1(struct fields x) {
return x.f1;
}
int get_f2(struct fields x) {
return x.f2;
}
void set_f1(struct fields *x, unsigned v) {
x->f1 = v;
}
int main() {
struct fields x = {1, 2, -1};
printf("%d %d\n", get_f1(x), get_f2(x));
set_f1(&x, 4);
printf("%d %d\n", get_f1(x), get_f2(x));
}
|