[MLton-user] Calling C functions with a variable number of arguments

phil.clayton at lineone.net phil.clayton at lineone.net
Wed Jul 21 03:15:44 PDT 2010


Hi,

I have been using the FFI and have found it very flexible but have 
run 
into a problem that I can't see how to solve.  I am trying to call a 
C 
function with a variable number of arguments but need the variability 
in 
the number of arguments available in SML too.

The attached examples show that there is no problem importing a C 
function with a variable argument list for a fixed number of 
arguments: 
the files 'call_sum_<N>.sml' import the C function 'sum' with N 
arguments for the variable argument list.  I need to do something like

   val sum = _import "sum" : int * int list -> int;

(I am happy for the variable arguments to have the same type in SML.)
Does anyone have any ideas about how to achieve a similar effect?

Thanks,
Phil


-------------- next part --------------
A non-text attachment was scrubbed...
Name: call_c_var_arg_test.tgz
Type: application/x-gzip
Size: 691 bytes
Desc: not available
Url : http://mlton.org/pipermail/mlton-user/attachments/20100721/6c9f1eed/call_c_var_arg_test.bin


More information about the MLton-user mailing list