code wiki / (root) / smoke_struct.nx

smoke_struct.nx source

↩ module page · 17 lines · 322 B

1// smoke_struct.nx -- struct alloc + field write/read. 2 3import "syscalls.nx" 4 5struct Point { 6 x: i64, 7 y: i64, 8} 9 10func main() -> i64 { 11 let raw: *u8 = sys_mmap(32) 12 let p: *Point = raw as *Point 13 p.x = 17 14 p.y = 25 15 let s: i64 = p.x + p.y 16 return __syscall(93, s, 0, 0, 0, 0, 0) 17}