C/C++
-
编译器的选择(clang)
- C用clang
- C++用clang++
-
编译命令行
- 一步到位
- C++ : clang++ test.cpp header.cpp(or header.c 警告) -o(output) name.exe
- C : clang test.c header.c -o name.exe
- 分步执行:
- clang++ clang++ -c(complie) test.cpp header.cpp
- clang++ test.o header.o -o name.exe
- c类似
- 一步到位
-
编译时,不要加入头文件,直接加入头文件的对应目标文件
- 例:header.h -> header.cpp
-
程序的输出
- 默认输出 a.exe
- 通过 -o name.exe 把程序命名为name
- 通过 .\name 或者 .\name.exe 运行名为name程序, 不可直接name(or name.exe)不安全
-
特别的
- C++对应目标文件为cpp, hpp文件是可以直接写入定义的头文件
- hpp文件不需要主动写命令编译
- 例如:#include "testhpp.hpp" main.cpp 直接clang++ main.cpp -o name.exe即可