From 59446d7051a56aac4ef693335fb23c4faf86931c Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Mon, 22 Feb 2021 12:48:32 +0000 Subject: [PATCH] cgen: use `(void)` parameter list instead of `()` for type safety (#8898) --- vlib/v/gen/c/fn.v | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vlib/v/gen/c/fn.v b/vlib/v/gen/c/fn.v index f5ee9d85ca..1eccba696d 100644 --- a/vlib/v/gen/c/fn.v +++ b/vlib/v/gen/c/fn.v @@ -351,6 +351,10 @@ fn (mut g Gen) write_defer_stmts_when_needed() { fn (mut g Gen) fn_args(args []table.Param, is_variadic bool) ([]string, []string) { mut fargs := []string{} mut fargtypes := []string{} + if args.len == 0 { + // in C, `()` is untyped, unlike `(void)` + g.write('void') + } for i, arg in args { caname := if arg.name == '_' { g.new_tmp_var() } else { c_name(arg.name) } typ := g.unwrap_generic(arg.typ)