Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将结果放入OCaml中的字符串变量中_Ocaml_Frama C - Fatal编程技术网

将结果放入OCaml中的字符串变量中

将结果放入OCaml中的字符串变量中,ocaml,frama-c,Ocaml,Frama C,我有一个功能,它在offsetmap中打印出值: 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"

我有一个功能,它在offsetmap中打印出值:

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
替换为
Format.sprintf
而不是
Printf.sprintf
不幸的是,您是正确的:
Format.sprintf
没有正确的类型。在Frama-C中,函数
Pretty_utils.sfprintf
将完全满足您的需要。您可能还想看看
Pretty\u utils.to\u string

,不幸的是,鉴于
Format.sprintf
的类型,这不起作用
Format.sprintf“%a”
的类型为
(单位->'\u a->string)->'\u a->string
,而不是
(Format.formatter->'\u a->string)->'\u a->string
Error: This expression has type
      Format.formatter -> Cvalue.V_Offsetmap.t -> unit
    but an expression was expected of type unit -> 'a -> string