On 29/07/2025 15:58, Gergely Buday wrote:
Foreign.LowLevel.call has the following type:
Foreign.LowLevel.call;
val it = fn: LowLevel.cType list -> LowLevel.cType -> LowLevel.symbol -> LowLevel.Memory.voidStar * LowLevel.Memory.voidStar -> unit
I understood what the arguments are: the cType list is the type of arguments, the cType is the return type, the symbol is the C function symbol in the loaded library. But the two general pointers are not clear. Where should they point to? For a void argument function I gave
The first is the pointer to the arguments, the second is a pointer to the memory to receive the result. In this case because both the arguments and the result are void the values you pass are ignored.
However, I would strongly advise you to use the higher level functions Foreign.buildCallXXX . These will take care of allocating and freeing the argument and result vectors. Have a look at the sample code in the samplecode/Foreign directory. That directory contains both the C code and the ML code that calls it.
David