我有这个功能可以打印出偏移图中的值:
let pretty_offsetmap_original lv fmt offsetmap =
begin match offsetmap with
| None -> Format.fprintf fmt "<BOTTOM>"
| Some off ->
let typ = Some (typeOfLval lv)
in
Format.fprintf fmt "%a%a"
pretty_lval_or_absolute lv
(Cvalue.V_Offsetmap.pretty_typ typ) off
end
现在,我想将值放入一个字符串变量中,以便出于我的目的对其进行转换。我替换Format.fprintf fmt
了,Printf.sprintf
但它不起作用。编译错误:
Error: This expression has type
Format.formatter -> Cvalue.V_Offsetmap.t -> unit
but an expression was expected of type unit -> 'a -> string