简体   繁体   English

OS X中的“ C语:错误:无输入文件”

[英]“Clang: error: no input files” in OS X

Following this solution , I use #include "...frontend/tokens.mll" in my lexer.mll , then I use cpp -P frontend/lexer.mll -o frontend/gen/lexer.mll to generate the complete mll file. 按照此解决方案 ,我在lexer.mll使用#include "...frontend/tokens.mll" ,然后使用cpp -P frontend/lexer.mll -o frontend/gen/lexer.mll生成完整的mll文件。 This solution worked before under Ubuntu. 此解决方案以前曾在Ubuntu下使用。

Now, I try to do this in Mac OS 10.11.1 , it gives an error clang: error: no input files . 现在,我尝试在Mac OS 10.11.1执行此Mac OS 10.11.1 ,它发出一个错误提示clang: error: no input files

gcc -v returns gcc -v返回

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

I don't see where I use XCode, or PCH file. 我看不到在哪里使用XCode或PCH文件。 Does anyone know how I should configure the environment to make cpp work? 有谁知道我应该如何配置环境以使cpp工作?

Edit 1: 编辑1:

cpp --version returns cpp --version返回

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

And an example from the comment: 还有一个来自注释的示例:

在此处输入图片说明

So if I understand correctly what you are trying to do, you want to run the c preprocessor on a file to produce text output which will be stored in another file. 因此,如果我正确理解了您要执行的操作,则希望对文件运行c预处理程序以生成文本输出,该文本输出将存储在另一个文件中。 I don't know why but, here is a command that will accomplish that : 我不知道为什么,但是,这是一个可以完成此操作的命令:

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

This invokes clang; 这会调用clang; sets the language to C ( -xc ); 将语言设置为C( -xc ); gives your file; 提供您的文件; asks for preprocessing only, no compile or link ( -E ); 仅要求预处理,不要求编译或链接( -E ); no line info in the output ( -P ), stores it in frontend/gen/lexer.mll 输出( -P )中没有行信息,将其存储在frontend / gen / lexer.mll中

Xcode is an IDE that runs clang. Xcode是运行clang的IDE。 If you are working in ocaml it may not be helpful to use Xcode since it wouldn't know what to do with ocaml files. 如果您使用的是ocaml,则使用Xcode可能无济于事,因为它不知道如何处理ocaml文件。

It could be a bug from clang, as this one works for me: 这可能是clang的一个错误,因为它对我有用:

$ cpp -P xxx yyy
$ cat yyy
from zzz

and

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

1 - open XCode 1-打开XCode

2 - Create a new XCode project 2-创建一个新的XCode项目

3 - choose tab of OSX 3-选择OSX标签

4 - choose Application 4-选择应用

5 - choose Command Line tool 5-选择命令行工具

6 - in next window you have to enter product name etc 6-在下一个窗口中,您必须输入产品名称等

7 - and choose c++ as a language 7-选择c ++作为语言

'cpp -P xxx -o yyy'您需要它成为->'echo“ blahblahblah.cpp”> xxx'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM