Skip to content

Commit

Permalink
Fix incompatible function pointer errors in clang
Browse files Browse the repository at this point in the history
  • Loading branch information
Nycto committed Feb 11, 2025
1 parent 49b709e commit 65ecc3c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/playdate/bindings/system.nim
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ type PDMenuItemCallbackFunctionRaw {.importc: "PDMenuItemCallbackFunction", head
# System
sdktype:
type PlaydateSys* {.importc: "const struct playdate_sys", header: "pd_api.h".} = object
realloc {.importc: "realloc".}: proc (`ptr`: pointer; size: csize_t): pointer {.cdecl, raises: [], tags: [], gcsafe.}
realloc {.importc: "realloc".}: PDRealloc
formatString {.importc: "formatString".}: proc (ret: cstringArray; fmt: cstring): cint {.
cdecl, varargs, raises: [].}
logToConsole {.importc: "logToConsole".}: proc (fmt: ConstChar) {.cdecl, varargs, raises: [].}
logToConsole {.importc: "logToConsole".}: PDLog
error {.importc: "error".}: proc (fmt: cstring) {.cdecl, varargs, raises: [].}
getLanguage {.importsdk.}: proc (): PDLanguage
getCurrentTimeMilliseconds {.importsdk.}: proc (): cuint
Expand Down
14 changes: 10 additions & 4 deletions src/playdate/bindings/types.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
type ConstChar* {.importc: "const char*".} = cstring
type ConstCharPtr* {.importc: "const char**".} = cstring
type Char* {.importc: "char*".} = cstring
type
ConstChar* {.importc: "const char*".} = cstring
ConstCharPtr* {.importc: "const char**".} = cstring
Char* {.importc: "char*".} = cstring
LCDBitmapPtr* {.importc: "LCDBitmap*", header: "pd_api.h".} = pointer

type LCDBitmapPtr* {.importc: "LCDBitmap*", header: "pd_api.h".} = pointer
PDLog* = proc (fmt: ConstChar) {.cdecl, varargs, raises: [].}
## The type signature for playdate.system.logToConsole

PDRealloc* = proc (p: pointer; size: csize_t): pointer {.tags: [], raises: [], cdecl, gcsafe.}
## The type signature for playdate.system.realloc
4 changes: 1 addition & 3 deletions src/playdate/util/initreqs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
## completely self contained.
##

type
PDRealloc* = proc (p: pointer; size: csize_t): pointer {.tags: [], raises: [], cdecl, gcsafe.}
PDLog* = proc (fmt: cstring) {.cdecl, varargs, raises: [].}
import ../bindings/types

var pdrealloc*: PDRealloc
var pdlog*: PDLog
Expand Down

0 comments on commit 65ecc3c

Please sign in to comment.