| 1 | struct Struct { |
| 2 | name string |
| 3 | x int |
| 4 | } |
| 5 | |
| 6 | fn main() { |
| 7 | unsafe { |
| 8 | pb := &u8(0) |
| 9 | ppb := &&u8(0) |
| 10 | pppb := &&&u8(0) |
| 11 | ppppb := &&&&u8(0) |
| 12 | dump(voidptr(pb)) |
| 13 | dump(voidptr(ppb)) |
| 14 | dump(voidptr(pppb)) |
| 15 | dump(voidptr(ppppb)) |
| 16 | pc := &char(nil) |
| 17 | ppc := &&char(nil) |
| 18 | pppc := &&&char(nil) |
| 19 | ppppc := &&&&char(nil) |
| 20 | dump(voidptr(pc)) |
| 21 | dump(voidptr(ppc)) |
| 22 | dump(voidptr(pppc)) |
| 23 | dump(voidptr(ppppc)) |
| 24 | ps := &Struct(0) |
| 25 | pps := &&Struct(0) |
| 26 | ppps := &&&Struct(0) |
| 27 | pppps := &&&&Struct(0) |
| 28 | dump(voidptr(ps)) |
| 29 | dump(voidptr(pps)) |
| 30 | dump(voidptr(ppps)) |
| 31 | dump(voidptr(pppps)) |
| 32 | } |
| 33 | ss := &Struct{ |
| 34 | name: 'abc' |
| 35 | x: 123 |
| 36 | } |
| 37 | dump(ss) |
| 38 | pss := voidptr(ss) |
| 39 | if &Struct(pss).name == 'abc' { |
| 40 | println('ok') |
| 41 | } |
| 42 | if &Struct(pss).x == 123 { |
| 43 | // &Struct cast and selecting .x |
| 44 | println('ok') |
| 45 | } |
| 46 | if &&Struct(pss) != 0 { |
| 47 | // &&Struct |
| 48 | println('ok') |
| 49 | } |
| 50 | } |
| 51 |