From dc2d152649ae4a1c8ca2579600ee78f6b691c8ee Mon Sep 17 00:00:00 2001 From: kbkpbot Date: Fri, 3 Jan 2025 10:12:20 +0800 Subject: [PATCH] fix windows --- vlib/v/gen/c/cgen.v | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 4a8cbd46bae078..79a6bad86a3365 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -6094,6 +6094,13 @@ fn (mut g Gen) write_init_function() { defer { util.timing_measure(@METHOD) } + + // Force generate _vinit_caller, _vcleanup_caller , these are needed under Windows, + // because dl.open() / dl.close() will call them when loading/unloading shared dll. + if g.pref.is_liveshared && g.pref.os != .windows { + return + } + fn_vinit_start_pos := g.out.len // ___argv is declared as voidptr here, because that unifies the windows/unix logic