Browse thread
[Caml-list] Problem with external function
- Jonathan Roewen
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2005-12-29 (01:52) |
From: | Jonathan Roewen <jonathan.roewen@g...> |
Subject: | [Caml-list] Problem with external function |
Hi, I have a weird problem with ocaml and my external function. It seems it never gets called, and ocaml appears to lockup. This may be that problem with compare function coming back to haunt me, so if anyone has some clues, it'd really make my day! In iO.ml (Pervasives IO is built on top of this module), I have: external write_ex : char -> unit = "caml_output_char" (*let write_ex _ = raise Output_closed*) let stdout = let output string off len = for i = off to len - off - 1 do write_ex string.[i] done in let seek = (fun _ -> raise Seek_unsupported) and tell = (fun _ -> 0) in create_out write_ex output seek tell default_close default_flush default_length Now, if I make it raise an exception, then it gets raised as a fatal exception, and ocaml tidies up after itself -- all nice and good. When I try to call the external function, nothing happens. At the very least, it should exit the kernel -- which means that it is -once again- getting stuck in some sort of infinite loop or other bizarre problem I have no idea about. The C function is very simple: CAMLprim value caml_output_char(value val) { CAMLparam1(val); caml_sys_error(NO_ARG); CAMLreturn(Val_unit); } which doesn't work. The proper version is to change second line to: dprintf("%c", Int_val(val)); which also doesn't work. dprintf works, as that is how fatal exceptions are printed. caml_output_char has been added to byterun files, and I output a list of caml primitives. I compile stdlib with -use-primitives byterun/primitives, and the same for my test.ml file. I also have a full tarball of the sources online if anyone would like to have a poke around (this is for my OS afterall, so a bit more complex than normal...), at http://dst.purevoid.org/dst-0.0.tar.bz2 This problem with external functions is making any development impossible =( Jonathan