v
v copied to clipboard
`$dbg` statement in `sdl/examples/basic_window` results in compile error
Describe the bug
$dbg statement in sdl/examples/basic_window results in compile error
Reproduction Steps
basic_window.v with the following contents:
module main
import sdl
fn main() {
sdl.init(sdl.init_video)
window := sdl.create_window('Hello SDL2'.str, 300, 300, 500, 300, 0)
renderer := sdl.create_renderer(window, -1, u32(sdl.RendererFlags.accelerated) | u32(sdl.RendererFlags.presentvsync))
mut should_close := false
for {
evt := sdl.Event{}
for 0 < sdl.poll_event(&evt) {
match evt.@type {
.quit { should_close = true }
else {}
}
}
if should_close {
break
}
$dbg // <- adding this yields a compile error
sdl.set_render_draw_color(renderer, 255, 55, 55, 255)
sdl.render_clear(renderer)
sdl.render_present(renderer)
}
sdl.destroy_renderer(renderer)
sdl.destroy_window(window)
sdl.quit()
}
Expected Behavior
Clean compile + run - and the debugger invoked
Current Behavior
v run examples/basic_window/
==================
/dev/shm/v_1000/basic_window.01HNJT6T4C374YQ9WZ2C5DPYX7.tmp.c:23075: warning: assignment discards qualifiers from pointer target type
/dev/shm/v_1000/basic_window.01HNJT6T4C374YQ9WZ2C5DPYX7.tmp.c:31646: error: cannot convert 'struct SDL_Window **' to 'struct SDL_Window'
...
==================
(Use `v -cg` to print the entire error message)
Possible Solution
???
Additional Information/Context
No response
V version
V 0.4.4 fb0efc0
Environment details (OS name and version, etc.)
Linux Arch based (Endeavor OS)
[!NOTE] You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote. Other reactions and those to comments will not be taken into account.
The fix in #20706 is only partial, it revealed a deeper problem with our automatic str method generation, for types that are aliases of C ones.
The fix in #20706 is only partial, it revealed a deeper problem with our automatic str method generation, for types that are aliases of C ones.
@spytheman can you provide a short reproducible case aliasing to C type when printing it breaks?
This is now fixed. Thanks @felipensp !