Skip to content

Commit

Permalink
cgen: use (void) parameter list instead of () for type safety (#8898
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ntrel committed Feb 22, 2021
1 parent f54c1a5 commit 59446d7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vlib/v/gen/c/fn.v
Expand Up @@ -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)
Expand Down

0 comments on commit 59446d7

Please sign in to comment.