diff options
Diffstat (limited to 'bootstrap/test.cff')
| -rw-r--r-- | bootstrap/test.cff | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/bootstrap/test.cff b/bootstrap/test.cff index e466bba..a000224 100644 --- a/bootstrap/test.cff +++ b/bootstrap/test.cff @@ -1,11 +1,12 @@ import "libc.hff"; import "libc.hff"; + union Val { - x i64, - lo i32, - y f64, + u u32, + f f32, } + enum Color { Red, Green, Blue } @@ -50,9 +51,16 @@ struct Vec2f { fn spanz(cstr *const u8) [#]const u8 { extern fn strlen(s *const u8) usize; - return cstr[0::strlen(cstr)]; + return cstr[0::strlen(cstr) + 1]; } +defmacro transmute(Type, x) [ + (do + union T { from typeof(x), to Type }; + T{x}.to; + ) +] + extern fn main (argc int, argv **u8) int { let colors [3]Color = { :Red, :Green, :Blue } ; @@ -77,6 +85,7 @@ extern fn main (argc int, argv **u8) int { printf("sizeof(is) = %zu\n", sizeof(is)); printf("sizeof *void = %zu\n", sizeof *void); + printf("1.2 -> %#.8x\n", transmute(u32, 1.2f)); return 0; |