> that's a 32-bit pointer to a function accepting a char array pointer 
> (cstring) and void return, right?

almost, same weirdness again with the way C defines its function pointers. it 
goes 
    
    
    returntype (*function_name)(argtypes...)
    
    
    Run

so that one's a 
    
    
    type s_vpi_sys_data = object
      ...
      calltf:proc(ptr PLI_BYTE8):PLI_INT32{.cdecl.}
      ...
    
    
    Run

again, i hate cdecl as it does nothing but make type errors (again, except on 
win32, where .nimcall is actually different) but technically it's the correct 
annotation.

but yes, even so that `task_data_p->calltf` is playing very fast and loose.

with gcc it does give a warning: 
    
    
    thing.c:27:25: warning: assignment to ‘int (*)(char *)’ from incompatible 
pointer type ‘void (*)()’ [-Wincompatible-pointer-types]
    
    
    Run

But yeah, it compiles and runs. ::shrugs in C::

the only way it wouldn't work is maybe on win32 fastcall (one of the few 
callee-cleanup calling conventions), if the caller expected to be sending >2 
arguments and so pushed some on to the stack which the callee (not expecting 
any) then didn't clean up. but i digress.

you should not do that, that's poor example code, and Nim will not allow you to 
do that. 

Reply via email to