mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
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:
parent
1bfeda6256
commit
f821c657a7
9 changed files with 90 additions and 43 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue