Hi there,
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
val monitorVoidStar = Foreign.System.loadLibrary "monitor.dll";
for both and it worked, but I guess one of them should be a pointer to the argument list. What is the meaning of these two pointers?
val monitorLib = Foreign.loadLibrary "monitor.dll";
val monitorVoidStar = Foreign.System.loadLibrary "monitor.dll";
fun main () = Foreign.LowLevel.call [] Foreign.LowLevel.cTypeVoid (Foreign.getSymbol monitorLib "say_hello") (monitorVoidStar, monitorVoidStar)
$ cat monitor.c #include <stdio.h>
void say_hello() {
printf("Hello from C!\n");
}
- Gergely