From ade62ba678686581eaff8f5ed7f3d99943415042 Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Sun, 18 Dec 2022 16:04:57 +0100 Subject: [PATCH] Use `output_file` to print to this file instead to `stdout` --- src/main.ml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main.ml b/src/main.ml index e4e38b8..3b40def 100644 --- a/src/main.ml +++ b/src/main.ml @@ -133,7 +133,14 @@ let _ = else ( if !nopopt then (fun _ -> ()) - else Format.printf "%a" Ast_to_c.ast_to_c) + else + ( + let oc = open_out !output_file in + let fmt = Format.make_formatter + (Stdlib.output_substring oc) + (fun () -> Stdlib.flush oc) in + Format.fprintf fmt "%a" Ast_to_c.ast_to_c); + ) end end