#error: expected type '[*c]cimport.struct_SDL_Surface', found '*cimport.struct_SDL_Surface'

1 messages · Page 1 of 1 (latest)

upbeat epoch
#

I'm getting the following error when I try to run code that I'm pretty sure used to work.

error: expected type '[*c]cimport.struct_SDL_Surface', found '*cimport.struct_SDL_Surface'

Did the Zig compiler change? I thought

Outside of automatically translated C code, the usage of [*c] is almost always a bad idea, and should almost never be used.

I tried casting my pointer but it gives the same error

const texture = sdl.SDL_CreateTextureFromSurface(self.sdlRenderer, @ptrCast(@as([*c]sdl.SDL_Surface, ctx._cairoItems.sdlSurface)));
fringe beacon
#

this error usually happens when you have multiple @cImports, you should only have 1 in the project

#

and your cast is kinda backwards, @as doesnt do any actual casting so thats triggering the same error before @ptrCast is even reached

upbeat epoch
#

It works if I do

const texture = sdl.SDL_CreateTextureFromSurface(self.sdlRenderer, @ptrFromInt(@intFromPtr(ctx._cairoItems.sdlSurface)));
fringe beacon
#

you should not do that

upbeat epoch
fringe beacon
#

yea thats just not really compatible with how cImport works