diff options
| author | 2022-08-05 07:28:56 +0200 | |
|---|---|---|
| committer | 2022-08-05 07:28:56 +0200 | |
| commit | 9667272414380e2d50113e0a0c6408a02e7c23eb (patch) | |
| tree | 9537c57f7b13aa43ce63553ca44d8ba42e6ed1c3 /bootstrap/test.cff | |
| parent | fc29f3f2b0c3a7c5ef1c75d910cf0815d2edbba2 (diff) | |
fn type syntax, bugfixs
Diffstat (limited to 'bootstrap/test.cff')
| -rw-r--r-- | bootstrap/test.cff | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/bootstrap/test.cff b/bootstrap/test.cff index 966176f..f74619a 100644 --- a/bootstrap/test.cff +++ b/bootstrap/test.cff @@ -17,6 +17,16 @@ enum Color { static xs *void = {}; +fn isort(xs *int, n usize) void { + extern fn qsort(base *void, nmemb usize, size usize, compar *fn(l *const void, r *const void, _ *void) int) void; + fn icmp(lhs *const void, rhs *const void, _ *void) int { + let lhs = *as(*int)lhs; + let rhs = *as(*int)rhs; + return lhs - rhs; + } + qsort(xs, n, 4, &icmp); +} + extern fn main (argc int, argv **u8) int { extern fn printf(fmt *const u8, ...) int; @@ -25,6 +35,7 @@ extern fn main (argc int, argv **u8) int { printf("v = { %g, %g }\n", x.x, x.y); let is [10]int = { [4] = 1, 2, [1 - 1] = 3 }; + isort(is, 10); for let i = 0; i < 10; ++i { printf("%d\n", is[i]); } |