Importing NimMain with msvc compiler fails.
balenamiaa opened this issue · 2 comments
The current specified way of importing NimMain from C is: proc NimMain() {.cdecl, importc.}
, but it gives the error:
error C2375: 'NimMain': redefinition; different linkage
note: see declaration of 'NimMain'
It seems the import generates this C code: N_CDECL(void, NimMain)(void);
but NimMain is defined at the end of the file like so: N_LIB_EXPORT N_CDECL(void, NimMain)(void)
thus the different linkage. Now It can be solved like this, albeit ugly:
proc NimMain() {.cdecl, importc, noDecl.}
{.emit:"N_LIB_EXPORT N_CDECL(void, NimMain)(void);".}
I'm assuming you're compiling this from Windows? Good to know. I can add it to the README but this repo is intended to x-compile everything to windows from *nix or MacOS.
I am compiling from windows. This doesn't happen if I use the mingw toolchain though. If you don't think it brings value there's no need to add it :) . Most aren't going to use the vcc backend anyway.