我不明白为什么我不能用
编译我的程序 g++ -std=c++0x main.cpp Sale.h iProduct.h -o w7
每次我尝试使用此命令进行编译时,我都会收到 clang 错误
clang: error: cannot specify -o when generating multiple output files
该程序符合 a.out 标准,我知道我可以重命名 a.out 文件并继续使用,但我想知道为什么我会收到此错误以及我应该如何修复它。 谢谢
最佳答案
why I'm getting this error and how i should fix it may I ask why do the .h files affect it?
因为最近版本的gcc
可以编译头文件,
示例:
g++ test.h -o out
file out
out: GCC precompiled header (version 014) for C++
在这种情况下,它 (gcc
) 生成预编译文件 ( https://en.wikipedia.org/wiki/Precompiled_header )。
所以当你同时编译.cpp
文件和header时,
它无法决定输出的是预编译头文件还是 elf 可执行文件。
关于C++编译clang错误多个输出文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33619046/