I have been using GodotNim for more than a year now with no issues. A couple of days ago it stopped working with the following error:
/Users/stefanlund/.cache/nim/backend_d/@mgodot@[email protected]:5046:6: error: call to undeclared function 'NimMain'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
NimMain();
^
1 error generated.
Error: execution of an external compiler program 'clang -c -w -ferror-limit=3 -pthread -fPIC -I/opt/homebrew/Cellar/nim/1.6.12/nim/lib -I/Users/projects/turing_complete/dyn_lib -o /Users/stefanlund/.cache/nim/backend_d/@mgodot@[email protected] /Users/stefanlund/.cache/nim/backend_d/@mgodot@[email protected]' failed with exit code: 1
It only fails to find NimMain() on my m1 mac. I reformatted the mac to make sure I hadn't messed something up, but it still doesn't work so I think it must have something to do with the latest macos update. I tested and it still works on Windows.
In the file godotnim.nim on line 890 i see this:
{.emit: """
NimMain();
""".}
If I comment that out, the project compiles again, but the library it produces instantly crashes. I am not familiar with nim internals so I am kind of at a dead end. Any ideas on how I can fix this?
Change the .emit to:
{.emit: """
void NimMain(void);
NimMain();
""".}
ISO C99 and later do not support implicit function declarations
It's only available when its phototype is decleared.
Wouldn't it be better to change it to add this outside the procedure:
proc NimMain() {.importc, cdecl.}
and then this instead of the emit:
NimMain() # This is now just a normal Nim call