Skip to content

Commit

Permalink
fix bootstrapping with -cstrict
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Jan 3, 2025
1 parent 7b17589 commit 4b638b3
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions examples/hot_reload/message.v
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ mut:
@[live]
fn print_message(mut app App) {
info := live.info()
println('OK reloads: ${info.reloads_ok:4d} | Total reloads: ${info.reloads:4d} | Hello! Modify this message while the program is running.')
println('1 OK reloads: ${info.reloads_ok:4d} | Total reloads: ${info.reloads:4d} | Hello! Modify this message while the program is running.')
eprintln('>> app: ${voidptr(app)} | g_live_reload_info: ${voidptr(g_live_reload_info)}')
app.x = 9991 // try changing this to another value, while the program is running ...
app.x = 341 // try changing this to another value, while the program is running ...
app.counter++
dump(app)
}
Expand Down
5 changes: 2 additions & 3 deletions vlib/builtin/builtin.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ fn _memory_panic(fname string, size isize) {
$if freestanding || vinix {
eprint('size') // TODO: use something more informative here
} $else {
C.fprintf(C.stderr, c'%ld', size)
C.fprintf(C.stderr, c'%lld', size)
}
if size < 0 {
eprint(' < 0')
Expand Down Expand Up @@ -768,9 +768,8 @@ __global g_main_argc = int(0)
@[markused]
__global g_main_argv = unsafe { nil }

@[export: 'g_live_reload_info']
@[markused]
__global g_live_reload_info = unsafe { nil }
__global g_live_reload_info voidptr

// arguments returns the command line arguments, used for starting the current program as a V array of strings.
// The first string in the array (index 0), is the name of the program, used for invoking the program.
Expand Down
4 changes: 2 additions & 2 deletions vlib/v/gen/c/live.v
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ fn (mut g Gen) generate_hotcode_reloader_code() {
mut load_code := []string{}
if g.pref.os != .windows {
for so_fn in g.hotcode_fn_names {
load_code << 'impl_live_${so_fn} = dlsym(live_lib, "impl_live_${so_fn}");'
load_code << '\timpl_live_${so_fn} = dlsym(live_lib, "impl_live_${so_fn}");'
}
phd = posix_hotcode_definitions_1
} else {
for so_fn in g.hotcode_fn_names {
load_code << 'impl_live_${so_fn} = (void *)GetProcAddress(live_lib, "impl_live_${so_fn}"); '
load_code << '\timpl_live_${so_fn} = (void *)GetProcAddress(live_lib, "impl_live_${so_fn}"); '
}
phd = windows_hotcode_definitions_1
}
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/live/common.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ pub fn info() &LiveReloadInfo {
// All its fields will be 0, but still safe to access.
g_live_reload_info = &LiveReloadInfo{}
}
return &LiveReloadInfo(g_live_reload_info)
return unsafe { &LiveReloadInfo(g_live_reload_info) }
}
2 changes: 1 addition & 1 deletion vlib/v/live/executable/reloader.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub fn add_live_monitored_file(mut lri live.LiveReloadInfo, path string) {

@[if debuglive ?]
fn elog(r &live.LiveReloadInfo, s string) {
eprintln('> debuglive r: ${voidptr(r)} ${s}')
eprintln('> debuglive r: ${voidptr(r)} &g_live_reload_info: ${voidptr(&g_live_reload_info)} | g_live_reload_info: ${voidptr(g_live_reload_info)} ${s}')
}

fn compile_and_reload_shared_lib(mut r live.LiveReloadInfo) !bool {
Expand Down
4 changes: 4 additions & 0 deletions vlib/v/live/sharedlib/live_sharedlib.v
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
module sharedlib

import v.live as _

pub fn set_live_reload_pointer(p voidptr) {
eprintln('> set_live_reload_pointer, p: ${p}')
}

0 comments on commit 4b638b3

Please sign in to comment.