From 0050c1915ba45969663ec1f3a3a87ef76a42ab0e Mon Sep 17 00:00:00 2001 From: Alexey Date: Sat, 11 Apr 2020 19:38:51 +0300 Subject: [PATCH] cgen: call module `init` function if available --- vlib/v/gen/cgen.v | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index 70d2a8f3f3..ee1146a3fb 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -2132,6 +2132,14 @@ fn (g mut Gen) write_init_function() { g.writeln('\tbuiltin_init();') g.writeln('\tvinit_string_literals();') g.writeln(g.inits.str()) + for mod_name in g.table.imports { + init_fn_name := '${mod_name}.init' + if _ := g.table.find_fn(init_fn_name) { + mod_c_name := mod_name.replace('.', '__') + init_fn_c_name := '${mod_c_name}__init' + g.writeln('\t${init_fn_c_name}();') + } + } g.writeln('}') if g.autofree { g.writeln('void _vcleanup() {')