1 (* foo_program.ml -- the program using foolib *)
3 open Swig (* Give access to the swig library *)
4 open Foolib (* This is the name of your swig output *)
6 let results = _foo '() (* Function names are prefixed with _ in order to make
7 them lex as identifiers in ocaml. Consider that
8 uppercase identifiers are module names in ocaml.
9 NOTE: the '() syntax is part of swigp4. You can do:
10 let results = _foo C_void *)
12 (* Since your function has a return value in addition to the string output,
13 you'll need to match them as a list *)
17 C_list [ C_string result_string ; C_int 0 ] -> (* The return value is
18 last when out arguments appear, but this too can be customized.
19 We're also checking that the function succeeded. *)
21 | _ -> raise (Failure "Expected string, int reply from _foo")
23 let _ = print_endline result_string