clang ++ -c标志有什么作用?

时间:2014-05-07 23:45:11

标签: c++ shell unix clang clang++

-c 标志在以下命令中的作用是什么?

clang++ -std=c++11 -g -Wall -stdlib=libc++ -isystem testing/gtest-1.7.0/include -Itesting/gtest-1.7.0 -pthread -c testing/gtest-1.7.0/src/gtest-all.cc

我已在文档(http://clang.llvm.org/docs/UsersManual.html)以及帮助消息(clang -cc1 --help)中查找了该标记...似乎无法找到答案

3 个答案:

答案 0 :(得分:4)

man clang++

OPTIONS
   Stage Selection Options
       -E  Run the preprocessor stage.

       -fsyntax-only
           Run the preprocessor, parser and type checking stages.

       -S  Run the previous stages as well as LLVM generation and optimization stages and target-specific code generation, producing an assembly file.

       -c  Run all of the above, plus the assembler, generating a target ".o" object file.

答案 1 :(得分:3)

-c标志用于告诉编译器您不想构建程序(链接到可执行文件中),只需将此特定文件编译为目标文件 - 通常会生成一个名为something.o或something.obj - 在这种情况下gteger-all.cc

(请注意,这个标志在几乎所有可用的编译器中都很常见 - 从1990年的Turbo C到最新版本的MS,Gnu和LLVM / Clang)

答案 2 :(得分:2)

man clang 是你的朋友!

OPTIONS
   Stage Selection Options
       -E  Run the preprocessor stage.

       -fsyntax-only
           Run the preprocessor, parser and type checking stages.

       -S  Run the previous stages as well as LLVM generation and optimization
           stages and target-specific code generation, producing an assembly
           file.

       -c  Run all of the above, plus the assembler, generating a target ".o"
           object file.