fix cross

This commit is contained in:
kbkpbot 2025-08-24 09:01:51 +08:00
parent b98a99649a
commit 2a7735f7d4
5 changed files with 12 additions and 2 deletions

View file

@ -421,7 +421,7 @@ fn (mut c Checker) if_expr(mut node ast.IfExpr) ast.Type {
} }
} }
if comptime_remove_curr_branch_stmts { if comptime_remove_curr_branch_stmts && !c.pref.output_cross_c {
// remove the branch statements since they may contain OS-specific code. // remove the branch statements since they may contain OS-specific code.
branch.stmts = [] branch.stmts = []
} }

View file

@ -494,7 +494,7 @@ fn (mut g Gen) comptime_if(node ast.IfExpr) {
if should_create_scope { if should_create_scope {
g.writeln('{') g.writeln('{')
} }
if is_true.val { if is_true.val || g.pref.output_cross_c {
g.stmts(branch.stmts) g.stmts(branch.stmts)
} }
if should_create_scope { if should_create_scope {

View file

@ -0,0 +1,7 @@
total_m += n;
fprintf(stderr, "_v_malloc %6d total %10d\n", n, total_m);
return prealloc_malloc(n);
res = GC_MALLOC(n);
res = _aligned_malloc(n, 1);
res = malloc(n);
memset(res, 0x4D, n);

View file

@ -0,0 +1 @@
hello

View file

@ -0,0 +1,2 @@
// vtest vflags: -cross -printfn _v_malloc
println('hello')