Call a foreign-language function: Difference between revisions

→‎{{header|OCaml}}: fixed typo, and add length parameter for array
(Add Never)
(→‎{{header|OCaml}}: fixed typo, and add length parameter for array)
Line 1,634:
<lang ocaml>void myfunc_a();
float myfunc_b(int, float);
char *myfunc_c(int *, int);</lang>
 
The header file is named "<tt>mylib.h</tt>", and linked against the library with <tt>-lmylib</tt> and compiled with <tt>-I/usr/include/mylib</tt>.
Line 1,657:
 
CAMLprim value
caml_myfunc_b(value a;, value b) {
float c = myfunc_b(Int_val(a), Double_val(b));
return caml_copy_double(c);
Line 1,672:
arr[i] = Int_val(Field(ml_array, i));
}
s = myfunc_c(arr, len);
free(arr);
return caml_copy_string(s);