mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
fix cross
This commit is contained in:
parent
b98a99649a
commit
2a7735f7d4
5 changed files with 12 additions and 2 deletions
|
@ -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 = []
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
7
vlib/v/gen/c/testdata/cross_printfn_v_malloc.c.must_have
vendored
Normal file
7
vlib/v/gen/c/testdata/cross_printfn_v_malloc.c.must_have
vendored
Normal 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);
|
1
vlib/v/gen/c/testdata/cross_printfn_v_malloc.out
vendored
Normal file
1
vlib/v/gen/c/testdata/cross_printfn_v_malloc.out
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
hello
|
2
vlib/v/gen/c/testdata/cross_printfn_v_malloc.vv
vendored
Normal file
2
vlib/v/gen/c/testdata/cross_printfn_v_malloc.vv
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
// vtest vflags: -cross -printfn _v_malloc
|
||||||
|
println('hello')
|
Loading…
Add table
Add a link
Reference in a new issue