Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i tried the compile simple sdl window file from sdl example, it shows this error #21870

Closed
Itsr1ght opened this issue Jul 14, 2024 · 3 comments
Closed

Comments

@Itsr1ght
Copy link

Itsr1ght commented Jul 14, 2024

V doctor:

V full version: V 0.4.6 e8eda21
OS: linux, "Arch Linux"
Processor: 12 cpus, 64bit, little endian, AMD Ryzen 5 5600G with Radeon Graphics

getwd: /home/r1ght/Desktop/gits/sdl
vexe: /usr/lib/vlang/v
vexe mtime: 2024-07-14 16:02:19

vroot: NOT writable, value: /usr/lib/vlang
VMODULES: OK, value: /home/r1ght/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.45.2
Git vroot status: Error: fatal: not a git repository (or any of the parent directories): .git
.git/config present: false

CC version: cc (GCC) 14.1.1 20240522
thirdparty/tcc status: Error: fatal: detected dubious ownership in repository at '/usr/lib/vlang/thirdparty/tcc'
To add an exception for this directory, call:

	git config --global --add safe.directory /usr/lib/vlang/thirdparty/tcc
 Error: fatal: detected dubious ownership in repository at '/usr/lib/vlang/thirdparty/tcc'
To add an exception for this directory, call:

	git config --global --add safe.directory /usr/lib/vlang/thirdparty/tcc


What did you do?
v -g -o vdbg cmd/v && vdbg examples/basic_window/main.v

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
		}

		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()
}

What did you expect to see?

a simple sdl window

What did you see instead?

==================
/tmp/v_1000/main.01J2S26BDWVR8GN9SN9XHJ9YD2.tmp.c:2024: error: ';' expected (got "sdl__OSEvent")
...
==================
(Use `v -cg` to print the entire error message)

builder error: 
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

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.

@Itsr1ght
Copy link
Author

Itsr1ght commented Jul 14, 2024

I changed the compiler to Clang using --cc, but the same issue persisted

@larpon
Copy link
Contributor

larpon commented Jul 14, 2024

The sdl project branch needs to match the major and minor version of the SDL2 version installed on your system. Have you followed the project README.md install instructions? Versions are handled via git branches. Since you are on Arch Linux you might want to use the 2.30.0 branch of vlang/sdl

@Itsr1ght
Copy link
Author

Thanks, I didn't see that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants