Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Dec 21, 2024
1 parent 76e17bd commit 07d7406
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vlib/v/checker/fn.v
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,7 @@ fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool) ast.
|| param.typ == ast.nil_type || final_param_sym.idx == ast.nil_type_idx)
&& !call_arg.typ.is_any_kind_of_pointer() && func.language == .v
&& !call_arg.expr.is_lvalue() && !c.pref.translated && !c.file.is_translated
&& func.name !in ['json.encode', 'json.encode_pretty'] {
&& !func.is_c_variadic && func.name !in ['json.encode', 'json.encode_pretty'] {
c.error('expression cannot be passed as `voidptr`', call_arg.expr.pos())
}
// Handle expected interface
Expand Down
1 change: 1 addition & 0 deletions vlib/v/gen/c/testdata/literal_c_variadic_arg.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo : 1 : 2.50, 42, v
22 changes: 22 additions & 0 deletions vlib/v/gen/c/testdata/literal_c_variadic_arg.vv
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <stdarg.h>

@[typedef]
struct C.va_list {}

fn C.va_start(voidptr, voidptr)
fn C.va_end(voidptr)

fn C.vfprintf(&C.FILE, &char, C.va_list) int

fn t2(fmt voidptr, ...) {
ap := C.va_list{}
C.va_start(ap, fmt)
C.vfprintf(C.stderr, fmt, ap)
C.va_end(ap)
}

fn main() {
a := 1
b := 2.5
t2(c'%s : %d : %.2f, %d, %c\n', c'foo', a, b, 42, `v`)
}

0 comments on commit 07d7406

Please sign in to comment.