diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index a280086699..6205c731a6 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -822,9 +822,6 @@ static inline void __${typ.cname}_pushval($typ.cname ch, $el_stype val) { .map { g.type_definitions.writeln('typedef map $typ.cname;') } - .function { - g.write_fn_typesymbol_declaration(typ) - } else { continue } @@ -835,6 +832,11 @@ static inline void __${typ.cname}_pushval($typ.cname ch, $el_stype val) { g.write_alias_typesymbol_declaration(typ) } } + for typ in g.table.type_symbols { + if typ.kind == .function && typ.name !in c.builtins { + g.write_fn_typesymbol_declaration(typ) + } + } // Generating interfaces after all the common types have been defined // to prevent generating interface struct before definition of field types for typ in g.table.type_symbols { diff --git a/vlib/v/tests/fn_test.v b/vlib/v/tests/fn_test.v index 591f6b15be..b85fb9aa4d 100644 --- a/vlib/v/tests/fn_test.v +++ b/vlib/v/tests/fn_test.v @@ -44,6 +44,9 @@ type F6 = fn (int, int) type F7 = fn (time.Time, int) +type MyTime = time.Time +type F8 = fn (MyTime) + fn C.atoi(&byte) int fn C.freec(ptr voidptr)