@@ -274,7 +274,7 @@ fn (mut g Gen) gen_fn_decl(node &ast.FnDecl, skip bool) {
274
274
g.write (fn_header)
275
275
}
276
276
arg_start_pos := g.out.len
277
- fargs , fargtypes , heap_promoted := g.fn_args (node.params, node.scope)
277
+ fargs , fargtypes , heap_promoted := g.fn_decl_params (node.params, node.scope, node.is_variadic )
278
278
if is_closure {
279
279
mut s := '$cur_closure_ctx *$c.closure_ctx '
280
280
if node.params.len > 0 {
@@ -537,16 +537,15 @@ fn (mut g Gen) write_defer_stmts_when_needed() {
537
537
}
538
538
}
539
539
540
- // fn decl args
541
- fn (mut g Gen) fn_args (args []ast.Param, scope & ast.Scope) ([]string , []string , []bool ) {
540
+ fn (mut g Gen) fn_decl_params (params []ast.Param, scope & ast.Scope, is_variadic bool ) ([]string , []string , []bool ) {
542
541
mut fargs := []string {}
543
542
mut fargtypes := []string {}
544
543
mut heap_promoted := []bool {}
545
- if args .len == 0 {
544
+ if params .len == 0 {
546
545
// in C, `()` is untyped, unlike `(void)`
547
546
g.write ('void' )
548
547
}
549
- for i, arg in args {
548
+ for i, arg in params {
550
549
mut caname := if arg.name == '_' { g.new_tmp_declaration_name () } else { c_name (arg.name) }
551
550
typ := g.unwrap_generic (arg.typ)
552
551
arg_type_sym := g.table.sym (typ)
@@ -556,7 +555,7 @@ fn (mut g Gen) fn_args(args []ast.Param, scope &ast.Scope) ([]string, []string,
556
555
func := info.func
557
556
g.write ('${g.typ(func.return_type)} (*$caname )(' )
558
557
g.definitions.write_string ('${g.typ(func.return_type)} (*$caname )(' )
559
- g.fn_args (func.params, voidptr (0 ))
558
+ g.fn_decl_params (func.params, voidptr (0 ), func.is_variadic )
560
559
g.write (')' )
561
560
g.definitions.write_string (')' )
562
561
fargs << caname
@@ -586,11 +585,15 @@ fn (mut g Gen) fn_args(args []ast.Param, scope &ast.Scope) ([]string, []string,
586
585
fargtypes << arg_type_name
587
586
heap_promoted << heap_prom
588
587
}
589
- if i < args .len - 1 {
588
+ if i < params .len - 1 {
590
589
g.write (', ' )
591
590
g.definitions.write_string (', ' )
592
591
}
593
592
}
593
+ if g.pref.translated && is_variadic {
594
+ g.write (', ...' )
595
+ g.definitions.write_string (', ...' )
596
+ }
594
597
return fargs, fargtypes, heap_promoted
595
598
}
596
599
0 commit comments