一個字符串變量我有這個功能的工作,其打印出的offsetmap值:獲取導致進入OCaml中
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
現在我想獲得的價值在一個字符串變量轉化爲我的目的。我用Printf.sprintf
替換了Format.fprintf fmt
,但它不起作用。該編譯錯誤:
Error: This expression has type
Format.formatter -> Cvalue.V_Offsetmap.t -> unit
but an expression was expected of type unit -> 'a -> string
它的工作原理,非常感謝鮑里斯 – user2544482