examples,builtin,cgen,live: fix windows hot reload with -cc tcc, improve the infrastructure, use a V global instead of a C one (fix #23214) (#23350)

This commit is contained in:
kbkpbot 2025-01-04 00:04:32 +08:00 committed by GitHub
parent 1bfeda6256
commit f821c657a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 90 additions and 43 deletions

View file

@ -4,15 +4,25 @@ module main
import time
import v.live
struct App {
mut:
x int
counter int
}
@[live]
fn print_message() {
info := live.info()
println('OK reloads: ${info.reloads_ok:4d} | Total reloads: ${info.reloads:4d} | Hello! Modify this message while the program is running.')
fn print_message(mut app App) {
i := live.info()
println('OK reloads: ${i.reloads_ok:4d} | Total reloads: ${i.reloads:4d} | Hello! Modify this message while the program is running. app: ${voidptr(app)} | app.x: ${app.x:6} | app.counter: ${app.counter:6}')
// app.x = 99 // try changing this to another value, while the program is running ...
app.counter++
}
fn main() {
unbuffer_stdout()
mut app := &App{}
for {
print_message()
print_message(mut app)
time.sleep(500 * time.millisecond)
}
}