#Parameter of type 'blah' must be declared comptime

1 messages · Page 1 of 1 (latest)

rich crystal
#

I am trying to move my Playdate game to stage 2 and the Playdate API is a series of function pointers. I changed all of my function pointers to be of type *const fn but I am still getting the error message:

/Users/danielbokser/playdate_puzzle/src/main.zig:26:28: error: parameter of type '*playdate_api_definitions.PlaydateAPI' must be declared comptime
pub export fn eventHandler(playdate: *pdapi.PlaydateAPI, event: pdapi.PDSystemEvent, arg: u32) c_int {

The PlaydateAPI struct has the definition:

pub const PlaydateAPI = extern struct {
    system: *const PlaydateSys,
    file: *const PlaydateFile,
    graphics: *const PlaydateGraphics,
    sprite: *anyopaque,
    display: *const PlaydateDisplay,
    sound: *const PlaydateSound,
    lua: *anyopaque,
    json: *anyopaque,
    scoreboards: *anyopaque,
};

I have no idea what field this error is coming from since all of function pointers have been converted to *const fn. Any ideas?

rich crystal
#

here's a part of PlaydateSys:

pub const PlaydateSys = extern struct {
    realloc: *const fn (ptr: ?*anyopaque, size: usize) callconv(.C) ?*anyopaque,
    formatString: *const fn (ret: ?*[*c]u8, fmt: [*c]const u8, ...) callconv(.C) c_int,
    logToConsole: *const fn (fmt: [*c]const u8, ...) callconv(.C) void,
    @"error": *const fn (fmt: [*c]const u8, ...) callconv(.C) void,
    getLanguage: *const fn () callconv(.C) PDLanguage,
    getCurrentTimeMilliseconds: *const fn () callconv(.C) c_uint,
    getSecondsSinceEpoch: *const fn (milliseconds: ?*c_uint) callconv(.C) c_uint,
    drawFPS: *const fn (x: c_int, y: c_int) callconv(.C) void,
rich crystal
broken obsidian
#

line 638

wheat moon
#

I concur.

rich crystal
# broken obsidian line 638

ah that was it! didn't think to search for , fn :/ thanks! now running into the same issue in a different part of the code 🙃