foreign name typ
exposes the C function of type typ
named by name
as an OCaml value.
The argument ?from
, if supplied, is a library handle returned by Dl.dlopen
.
The argument ?stub
, if true
(defaults to false
), indicates that the function should not raise an exception if name
is not found but return an OCaml value that raises an exception when called.
The value ?check_errno
, which defaults to false
, indicates whether Unix.Unix_error
should be raised if the C function modifies errno
. Please note that a function that succeeds is allowed to change errno. So use this option with caution.
The value ?release_runtime_lock
, which defaults to false
, indicates whether the OCaml runtime lock should be released during the call to the C function, allowing other threads to run. If the runtime lock is released then the C function must not access OCaml heap objects, such as arguments passed using Ctypes.ocaml_string
and Ctypes.ocaml_bytes
, and must not call back into OCaml.