我正在将 Ocaml 中的类型从int
转换为int32
. 我更改了String
Ocaml 库的一些功能(代码如下)
external length : string -> int32 = "%string_length"
external create: int32 -> string = "caml_create_string"
external unsafe_blit : string -> int32 -> string -> int32 -> int32 -> unit
= "caml_blit_string" "noalloc"
let sub s ofs len =
if ofs < 0l or len < 0l or add ofs len > length s
then invalid_arg "String.sub"
else begin
let r = create len in
unsafe_blit s ofs r 0l len;
r
end
请注意,我在int -> int32
运行代码时更改了代码中的很多地方,但出现错误:
./xsd2coq < grammar/cpf.xsd > coq/cpf.v
Segmentation fault (core dumped)
在文件xsd2coq.ml
中,我有一个缓冲区:
let main () =
let xml = parse_xml stdin in
let xsds = Xsd_of_xml.xsd_of_xml xml in
let b = Buffer.create 10000 in
Coq_of_xsd.genr_ml b xsds;
Buffer.output_buffer stdout b;;
let _ = run main;;
我想了解产生分段错误错误的原因是什么?你能给我任何提示或建议来调试我的代码吗?谢谢