Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SWIG - multiple params

2 views
Skip to first unread message

examachine

unread,
Jul 18, 2006, 4:28:03 PM7/18/06
to
In trying to wrap these functions as an exercise

int fact(int n) {
if (n <= 1) return 1;
else return n*fact(n-1);
}

int my_mod(int x, int y) {
return (x%y);
}


I fail with the latter:
# _fact (C_int 5);;
- : Example.c_obj = C_int 120
# _my_mod (C_int 6) (C_int 3);;
This function is applied to too many arguments, maybe you forgot a `;'

What's going on here? How do I accomplish this simple task?

BTW, the swig ocaml documentation is quite inadequate.

Best,

--
Eray

examachine

unread,
Jul 18, 2006, 5:19:20 PM7/18/06
to
I solved this, but you gotta admit this is a pretty silly usage and
it's not even documented properly...

nebula:swig-example$ ./mytop
Objective Caml version 3.09.2

# open Swig;;
# open Example;;
# let x = _my_mod( C_list [C_int 10; C_int 4]);;
val x : Example.c_obj = C_int 2
# print_int (get_int x);;
2- : unit = ()

I couldn't get ocamlp4 to work and even if it did I'm not used to it so
I have to stick with this. Grrrrrrrr.

Now, the "real" module that I'm trying to wrap segfaults. Great.

0 new messages