"Clang: error: no input files" in OS X

"Clang: error: no input files" in OS X

this solution之后,我在我的lexer.mll中使用#include "...frontend/tokens.mll",然后我使用cpp -P frontend/lexer.mll -o frontend/gen/lexer.mll生成完整的mll文件。此解决方案之前在 Ubuntu 下有效。

现在,我尝试在 Mac OS 10.11.1 中执行此操作,但出现错误 clang: error: no input files

gcc -v returns

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.29)
Target: x86_64-apple-darwin15.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

我看不到我在哪里使用 XCode 或 PCH 文件。有谁知道我应该如何配置环境才能使 cpp 工作?

编辑 1:

cpp --version returns

Apple LLVM version 7.3.0 (clang-703.0.29)
Target: x86_64-apple-darwin15.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

以及评论中的示例:

1 - 打开 XCode

2 - 创建一个新的 XCode 项目

3 - 选择 OSX

的选项卡

4 - 选择应用程序

5 - 选择命令行工具

6 - 接下来 window 您必须输入产品名称等

7 - 并选择 c++ 作为语言

'cpp -P xxx -o yyy' 你需要它 -> 'echo "blahblahblah.cpp" > xxx'

这可能是来自 clang 的错误,因为这个对我有用:

$ cpp -P xxx yyy
$ cat yyy
from zzz

$ clang --version
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin14.5.0
Thread model: posix

因此,如果我理解正确的话,您想要 运行 文件上的 c 预处理器以生成将存储在另一个文件中的文本输出。我不知道为什么,但是,这是一个可以完成该操作的命令:

clang -x c frontend/lexer.mll -E -P -o frontend/gen/lexer.mll

这会调用 clang;将语言设置为 C (-x c);给你的文件;仅要求预处理,不要求编译或 link (-E);输出中没有行信息 (-P),将其存储在 frontend/gen/lexer.mll

Xcode 是 IDE 运行 的叮当声。如果您在 ocaml 中工作,使用 Xcode 可能没有帮助,因为它不知道如何处理 ocaml 文件。