andrewrk / sdl-zig-demo

SDL2 hello world in zig
MIT License
116 stars 20 forks source link

sdl-zig-demo not building in Zig v0.9.1 on Debian 10 #11

Closed paralogismos closed 1 year ago

paralogismos commented 1 year ago

I noticed that this demo wouldn't build due to using c_void which is no longer supported. I updated that call to use anyopaque, and then got this error when building:

$ zig build
./zig-cache/o/7d0536ad2271b7a3554bfdda65614ef9/cimport.zig:23447:60: error: expected function, found '?fn([*c].cimport:1:11.struct_SDL_RWops) callconv(.C) c_int'
pub inline fn SDL_RWclose(ctx: anytype) @TypeOf(ctx.*.close(ctx)) {
                                                           ^
./zig-cache/o/7d0536ad2271b7a3554bfdda65614ef9/cimport.zig:23447:41: note: called from here
pub inline fn SDL_RWclose(ctx: anytype) @TypeOf(ctx.*.close(ctx)) {
                                        ^
./src/main.zig:6:21: note: called from here
pub fn main() !void {
                    ^

I can't make any sense out of this error. The problem certainly seems to be with calling SDL_RWclose; indeed, when the defer that contains this call is commented out the program builds and runs as expected.

The message error: expected function, found '?fn([*c].cimport:1:11.struct_SDL_RWops) callconv(.C) c_int' makes me wonder if there is something going wrong at the C interop layer.

I found a recent reference to the problem with c_void, but no other reports of this particular build problem.

paralogismos commented 1 year ago

This still does not build for me under Zig v0.9.1, but it does build and run as expected under the just-released Zig v0.10.0.