blob: 65b327900fa40aaa0654701421fce89ca6a43044 (
plain) (
blame)
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
37
38
39
40
|
extern malloc = (i64) => *void;
import "!stdlib.pry";
let test = struct {
x: i64,
y: *i8,
};
let print_struct = (s: test) => void {
printf("X: %d\n", s.x);
printf("Y: %s\n", s.y);
return;
};
let main = () => i64 {
let inst = cast(*test, malloc(sizeof(test)));
print_struct(*inst);
(*inst).x = 4;
(*inst).y = "hi";
print_struct(*inst);
return 0;
};
/*
Expected stdout:
X: 0
Y: (null)
X: 4
Y: hi
Expected return: 0
*/
|