From 66d9d481d93b6fd03a0b3459ade58d0907352549 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 21 Apr 2026 15:03:18 +0300 Subject: [PATCH] cgen: fix hot code reloading not working on windows (fixes #16256) --- vlib/v/gen/c/live.v | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/vlib/v/gen/c/live.v b/vlib/v/gen/c/live.v index 3682e542d..085213d55 100644 --- a/vlib/v/gen/c/live.v +++ b/vlib/v/gen/c/live.v @@ -4,6 +4,17 @@ import os import v.pref import v.util +fn live_runtime_quoted_path(target_os pref.OS, path string) string { + return match target_os { + .windows { '"${path.replace('"', '\\"')}"' } + else { "'" + path.replace("'", "'\\''") + "'" } + } +} + +fn live_runtime_quoted_path_for_c_string(target_os pref.OS, path string) string { + return live_runtime_quoted_path(target_os, path).replace('\\', '\\\\').replace('"', '\\"') +} + fn (mut g Gen) generate_hotcode_reloading_declarations() { if g.pref.os == .windows { g.hotcode_definitions.writeln('HANDLE live_fn_mutex = 0;') @@ -118,7 +129,7 @@ fn (mut g Gen) generate_hotcode_reloading_main_caller() { } vexe := util.cescaped_path(pref.vexe_path()) file := util.cescaped_path(g.pref.path) - ccpath := util.cescaped_path(g.pref.ccompiler) + ccpath := live_runtime_quoted_path_for_c_string(g.pref.os, g.pref.ccompiler) ccompiler := '-cc ${ccpath}' so_debug_flag := if g.pref.is_debug { '-cg' } else { '' } mut vopts := '${ccompiler} ${so_debug_flag} -sharedlive -shared' -- 2.39.5