5

我正在使用沙丘设置一个演示项目,并希望将可执行文件命名为“hello-world.exe”而不是“hello_world”。如果我尝试构建项目,我会收到编译器错误。如何在文件名中声明带有连字符的可执行文件?

我正在使用沙丘 1.9.3 和 OCaml 4.05.0。

沙丘:

(executable
 (name hello-world))

你好世界.ml

let () = print_endline "Hello, World!"

构建错误

$ dune build hello-world.exe
Info: creating file dune-project with this contents:
| (lang dune 1.9)

      ocamlc .hello-world.eobjs/byte/hello-world.{cmi,cmo,cmt} (exit 2)
(cd _build/default && /usr/bin/ocamlc.opt -w @a-4-29-40-41-42-44-45-48-58-59-60-40 -strict-sequence -strict-formats -short-paths -keep-locs -g -bin-annot -I .hello-world.eobjs/byte -no-alias-deps -opaque -o .hello-world.eobjs/byte/hello-world.cmo -c -impl hello-world.ml)
File "hello-world.ml", line 1:
Warning 24: bad source file name: "Hello-world" is not a valid module name.
File "hello-world.ml", line 1:
Error: Some fatal warnings were triggered (1 occurrences)
4

1 回答 1

4

您需要禁用警告 24:

(executable (name hello-world) (flags (:standard -w -24)))

要不就

(executable (name hello-world) (flags (:standard -warn-error -24)))

如果您希望保留警告

于 2019-06-11T14:41:20.987 回答