go-sdl2
go-sdl2 copied to clipboard
impossible type switch case: sdl.QuitEvent
Go version: go version go1.21.5 linux/amd64 Go-SDL2 version: v0.4.36 SDL2 version: 2.26.5+dfsg-1 OS: debian Architecture: amd64
When attempting to compile any of the examples, I get the following error:
./main.go:34:9: impossible type switch case: sdl.QuitEvent
event (variable of type sdl.Event) cannot have dynamic type sdl.QuitEvent (method GetTimestamp has pointer receiver)
The code generating the error is:
running := true
for running {
for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
switch event.(type) {
case sdl.QuitEvent:
println("Quit")
running = false
break
}
}
}
Hi @n-i-x, did you use the example from the master
branch which is for v0.5.x
? If so, could you try the example used by the v0.4.x
branch?
I had the same issue.
After changing to pointer
case *sdl.QuitEvent:
it works.
Hi @FandaLas, are you perhaps using the README of the master
branch? In the stable version v0.4.x
, we do use pointer.
Hi @FandaLas, are you perhaps using the README of the
master
branch? In the stable versionv0.4.x
, we do use pointer.
Confirmed. My mistake.