Lad*_*dih 2 c++ terminal codeblocks c++11
我创建了一个包含多个源文件和头文件的C++项目.该程序在代码块中编译和运行良好,但我无法在终端中编译它.
所有文件都在同一个文件夹中.
这是我输入的命令:
clang++ -std=c++11 main.cpp file1.cpp file1.h
Run Code Online (Sandbox Code Playgroud)
表明:
clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated
Run Code Online (Sandbox Code Playgroud)
还有一大堆错误:
error: use of undeclared identifier 'std'
Run Code Online (Sandbox Code Playgroud)
在头文件中.
Bia*_*sta 10
你应该避免编译头文件(.h).
试试:
clang++ -std=c++11 main.cpp file1.cpp
Run Code Online (Sandbox Code Playgroud)
头文件是预处理器将包含在需要它的cpp文件中的东西(那些使用预处理器指令的编译单元#include).