From 4a7d610bb9a441f6fb7f88caaa803c1c85e4fcfd Mon Sep 17 00:00:00 2001 From: lemon Date: Fri, 26 Aug 2022 22:08:52 +0200 Subject: bitfields --- test/2.cff | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test/2.cff (limited to 'test/2.cff') diff --git a/test/2.cff b/test/2.cff new file mode 100644 index 0000000..8b512ea --- /dev/null +++ b/test/2.cff @@ -0,0 +1,17 @@ +import "libc.hff"; + +bitfield Foo : uint { + tag 3, + flag (3, 1) bool, + num 10 signed, +} + +extern fn main() int { + let foo Foo = {}; + printf("0x%X: %d, %d, %d\n", foo.#raw, foo.tag, foo.flag, foo.num); + foo.tag = 3; + foo.#raw += 1; + foo.flag = #t; + foo.num = -2; + printf("0x%X: %d, %d, %d\n", foo.#raw, foo.tag, foo.flag, foo.num); +} -- cgit v1.2.3