【问题标题】:Is there a way to declare executables with hyphens in a OCaml dune?有没有办法在 OCaml 沙丘中用连字符声明可执行文件?
【发布时间】:2019-10-25 22:49:15
【问题描述】:

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

我正在使用 dune 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)

【问题讨论】:

标签: ocaml ocaml-dune


【解决方案1】:

您需要禁用警告24:

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

或者只是

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

如果您希望保留警告

【讨论】:

    猜你喜欢
    • 2021-07-10
    • 1970-01-01
    • 2014-11-19
    • 1970-01-01
    • 2022-10-07
    • 1970-01-01
    • 1970-01-01
    • 2010-09-24
    • 2020-05-19
    相关资源
    最近更新 更多