* [Caml-list] problem with Printf.printf when linking in bytecode interpreter to C app
@ 2004-01-26 3:42 Kip Macy
2004-01-26 4:56 ` SooHyoung Oh
0 siblings, 1 reply; 3+ messages in thread
From: Kip Macy @ 2004-01-26 3:42 UTC (permalink / raw)
To: caml-list
I've linked the ocaml runtime into my application:
this is my ocaml.ml:
let _ = Printf.printf "ocaml inited\n"
let foo () = Printf.printf "this works\n"
let rec fib n = if n < 2 then 1 else fib(n-1) + fib(n-2)
let _ = Callback.register "foo" foo
let _ = Callback.register "fib" fib
This is the relevant C code:
printf("calling caml_startup\n");
caml_startup(argv);
callback(*caml_named_value("foo"), Val_unit);
result = Int_val(callback(*caml_named_value("fib"), Val_int(6)));
printf("the result of fib is %d\n", result);
The only output I get is:
calling caml_startup
the result of fib is 13
Why don't the Printf.printf statements output anything?
Thanks.
-Kip
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] problem with Printf.printf when linking in bytecode interpreter to C app
2004-01-26 3:42 [Caml-list] problem with Printf.printf when linking in bytecode interpreter to C app Kip Macy
@ 2004-01-26 4:56 ` SooHyoung Oh
2004-01-26 5:52 ` Kip Macy
0 siblings, 1 reply; 3+ messages in thread
From: SooHyoung Oh @ 2004-01-26 4:56 UTC (permalink / raw)
To: Kip Macy, caml-list
It seems that the output buffer is not flushed.
Use "flush stdout" after Printf.printf.
For example,
let _ = Printf.printf "ocaml inited\n"; flush stdout
let foo () = Printf.printf "this works\n"; flush stdout
---
SooHyoung Oh
----- Original Message -----
From: "Kip Macy" <kmacy@fsmware.com>
To: <caml-list@inria.fr>
Sent: Monday, January 26, 2004 12:42 PM
Subject: [Caml-list] problem with Printf.printf when linking in bytecode
interpreter to C app
> I've linked the ocaml runtime into my application:
> this is my ocaml.ml:
> let _ = Printf.printf "ocaml inited\n"
>
> let foo () = Printf.printf "this works\n"
>
>
> let rec fib n = if n < 2 then 1 else fib(n-1) + fib(n-2)
>
> let _ = Callback.register "foo" foo
>
> let _ = Callback.register "fib" fib
>
>
> This is the relevant C code:
> printf("calling caml_startup\n");
> caml_startup(argv);
> callback(*caml_named_value("foo"), Val_unit);
> result = Int_val(callback(*caml_named_value("fib"), Val_int(6)));
> printf("the result of fib is %d\n", result);
>
>
> The only output I get is:
> calling caml_startup
> the result of fib is 13
>
> Why don't the Printf.printf statements output anything?
>
>
> Thanks.
>
> -Kip
>
> -------------------
> To unsubscribe, mail caml-list-request@inria.fr Archives:
http://caml.inria.fr
> Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ:
http://caml.inria.fr/FAQ/
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>
>
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] problem with Printf.printf when linking in bytecode interpreter to C app
2004-01-26 4:56 ` SooHyoung Oh
@ 2004-01-26 5:52 ` Kip Macy
0 siblings, 0 replies; 3+ messages in thread
From: Kip Macy @ 2004-01-26 5:52 UTC (permalink / raw)
To: SooHyoung Oh; +Cc: caml-list
Excellent. Thanks.
-Kip
On Mon, 26 Jan 2004, SooHyoung Oh wrote:
> It seems that the output buffer is not flushed.
> Use "flush stdout" after Printf.printf.
> For example,
>
> let _ = Printf.printf "ocaml inited\n"; flush stdout
> let foo () = Printf.printf "this works\n"; flush stdout
>
> ---
> SooHyoung Oh
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-01-26 5:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-26 3:42 [Caml-list] problem with Printf.printf when linking in bytecode interpreter to C app Kip Macy
2004-01-26 4:56 ` SooHyoung Oh
2004-01-26 5:52 ` Kip Macy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox