繁体   English   中英

clang ++编译模板类,在标头中实现

[英]clang++ compiling template class with implementation in header

$ make
clang++ -o build/blist.exe  src/driver.cpp src/BList.h -O0 -g -Wall -Wno-unused-parameter -Wextra -Wconversion -Wold-style-cast -std=c++14 -pedantic -Wold-style-cast
clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang: error: cannot specify -o when generating multiple output files

我的模板实现在BList.cpp ,但BList.h包括BList.cpp 这就是为什么我将标头作为对象传递的原因。 我不知道如何设置clang进行编译!


  • 根据我的教授,我的标头必须命名为“ BList.h”

  • 这些参数使用GCC编译,但是不能使用Clang编译。

该错误与在BList.h包含BList.cpp BList.h (尽管这本身就是一种可疑的做法)。

问题是您将src/BList.h传递给Clang,就好像它是源文件一样。 构建说明应为:

clang++ -o build/blist.exe  src/driver.cpp -O0 -g -Wall -Wno-unused-parameter -Wextra -Wconversion -Wold-style-cast -std=c++14 -pedantic -Wold-style-cast

您应该相应地更新您的makefile。

暂无
暂无

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

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