error: request for member 'ClPrc' in something not a structure or union
error: 'TMP142' undeclared (first use in this function)
error: request for member 'ClEnv' in something not a structure or union
Which I traced the nim generated C code link here, it looks like this section is the culprit:
memset((void*)(&LOC2), 0, sizeof(LOC2));
LOC2.ClPrc = ((TMP142) (waitforawhile_95072)); LOC2.ClEnv = NIM_NIL;
LOC3 = 0;
LOC3 = uv_idle_start(pidle_95099, LOC2);
I think nim should have just generated:
LOC3 = uv_idle_start(pidle_95099, waitforawhile_95072);
Can someone explain what I am doing wrong? I don't know what TMP142 and all this ClPrc / ClEnv is doing...
Common problem (and annoying the Nim compiler doesn't catch it), but proc type defaults to the .closure calling convention which is implemented as (fn, env) pair, incompatible with C. Use instead something like
type MyCallback = proc (a, b: cint): cstring {.cdecl.}
Awesome, that solved my problem. Thanks for responding so quickly.
I am new to Nim so I am just starting to wrap my head around these pragmas. Looks like there are still alot of things about Nim that I need to learn.
Have a good day!