Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nico/backends/sdl2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1829,9 +1829,10 @@ proc getRecordSeconds*(): int =
return 0

when defined(emscripten):
type cbool* {.importc: "bool", nodecl.} = uint8
Copy link

@mratsim mratsim Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type cbool* {.importc: "bool", nodecl.} = uint8
type cbool* {.importc: "bool", header:"<stdbool>".} = uint8

This will fail if stdbool is not imported, nodecl is used for compiler builtins, though it's possible that the compiler auto-imports stdbool and issues a warning. See https://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf p253
image

type em_callback_func* = proc() {.cdecl.}
{.push importc.}
proc emscripten_set_main_loop*(f: em_callback_func, fps, simulate_infinite_loop: cint)
proc emscripten_set_main_loop*(f: em_callback_func, fps: cint, simulate_infinite_loop: cbool)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
proc emscripten_set_main_loop*(f: em_callback_func, fps: cint, simulate_infinite_loop: cbool)
proc emscripten_set_main_loop*(f: em_callback_func, fps: cint, simulate_infinite_loop: bool)

Given that cbool and Nim bool both defer to _Bool it might be okay to reuse Nim bool here and it might be the reason why cbool doesn't exist in Nim.

I leave that choice to the maintainers of the library.

proc emscripten_cancel_main_loop*()
{.pop.}

Expand Down