ocamlfind的OCaml编译错误
代码如下:ocamlfind的OCaml编译错误,ocaml,ocamlfind,Ocaml,Ocamlfind,代码如下: class parser = let test1 = function | 1 -> print_int 1 | 2 -> print_int 2 | _ -> print_int 3 in let test = function | 1 -> print_int 1 | 2 -> print_int 2 | _ -> print_int 3 in object(self) end 这是\u标签 true: syntax(camlp4o)
class parser =
let test1 = function
| 1 -> print_int 1
| 2 -> print_int 2
| _ -> print_int 3 in
let test = function
| 1 -> print_int 1
| 2 -> print_int 2
| _ -> print_int 3 in
object(self)
end
这是\u标签
true: syntax(camlp4o)
true: package(deriving,deriving.syntax)
true: thread,debug,annot
true: bin_annot
下面是编译命令:
ocamlbuild -use-ocamlfind test.native
以下是编译错误:
Warning: tag "package" does not expect a parameter, but is used with parameter "deriving,deriving.syntax"
Warning: tag "syntax" does not expect a parameter, but is used with parameter "camlp4o"
+ /usr/local/bin/ocamldep.opt -modules test.ml > test.ml.depends
File "test.ml", line 8, characters 0-3:
Error: Syntax error
Command exited with code 2.
Compilation unsuccessful after building 1 target (0 cached) in 00:00:00.
但是,当我使用此选项时:
ocamlbuild test.native
然后可以成功编译代码…这是因为
ocamlbuild-use-ocamlfind test.native
指示编译器使用camlp4解析器。它与标准的OCaml解析器有点不同。实际上,parser
是camlp4中的一个关键字,所以不能将其用作类名。请重新命名。是的,我没想到会出现这样的错误,谢谢!