调试模板时出现问题.专门针对 Linux GCC 7、GCC 6、GCC 5、GCC 4.9 错误构建失败:模板参数 1
Problem in debugging templates. Build fails specifically for Linux GCC 7, GCC 6, GCC 5, GCC 4.9 error: template argument 1 is invalid
我的 Travis 仅在 Linux GCC 7、GCC 6、GCC 5、GCC 4.9 上失败,并显示错误
libs/astronomy/test/coordinate/equatorial_coord.cpp:22:57: error: template argument 1 is invalid
RightAscension<double, quantity<bud::plane_angle>>
^
libs/astronomy/test/coordinate/equatorial_coord.cpp:23:39: error: template argument 2 is invalid
ra(25.0 * bud::degrees);
这是equatorial_cord.cpp
#define BOOST_TEST_MODULE equatorial_coord_test
#include <iostream>
#include <boost/units/io.hpp>
#include <boost/units/quantity.hpp>
#include <boost/units/systems/angle/degrees.hpp>
#include <boost/units/systems/si/plane_angle.hpp>
#include <boost/astronomy/coordinate/coord_sys/equatorial_coord.hpp>
#include <boost/test/unit_test.hpp>
using namespace boost::astronomy::coordinate;
using namespace boost::units;
using namespace boost::units::si;
namespace bud = boost::units::degree;
namespace bu = boost::units;
BOOST_AUTO_TEST_SUITE(angle)
BOOST_AUTO_TEST_CASE(right_ascension) {
//Create object of Right Ascension
RightAscension<double, quantity<bud::plane_angle>>
ra(25.0 * bud::degrees);
//Check value
BOOST_CHECK_CLOSE(ra.get_angle().value(), 25.0, 0.001);
//Quantity stored as expected?
BOOST_TEST((std::is_same<decltype(ra.get_angle()), quantity<bud::plane_angle>>::value));
}
BOOST_AUTO_TEST_SUITE_END()
包括并使用 Equatorial_coord.hpp
#include <iostream>
#include <boost/units/io.hpp>
#include <boost/geometry/core/cs.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/units/systems/angle/degrees.hpp>
#include <boost/units/systems/si/plane_angle.hpp>
#include <boost/astronomy/coordinate/coord_sys/coord_sys.hpp>
namespace boost {
namespace astronomy {
namespace coordinate {
namespace bu = boost::units;
namespace bg = boost::geometry;
namespace bud = boost::units::degree;
//Right Ascension
template
<
typename CoordinateType = double,
typename RightAscensionQuantity = bu::quantity<bu::si::plane_angle, CoordinateType>
>
struct RightAscension {
private:
RightAscensionQuantity ra;
public:
RightAscension(){
ra = 0.0 * bu::si::radian;
};
RightAscension(RightAscensionQuantity const& _ra) : ra(_ra) {}
RightAscensionQuantity get_angle() const{
return static_cast<RightAscensionQuantity>(ra);
}
void print() {
std::cout << "Right Ascension: " << ra;
}
};
...
它在我的机器上完美构建,我已经尝试了一些代码变体,但我无法理解我错过了什么,特别是针对 Linux GCC 7、GCC 6、GCC 5、GCC 4.9 构建失败。
在这个项目中,我以类似的方式制作了许多标题,但从未遇到过这样的问题。如有任何建议,我将不胜感激。
https://dev.azure.com/lpranam/lpranam/_build/results?buildId=392&view=logs&j=d5b3eaca-5133-5bed-7ece-a6421a4fcca5&t=9b0787b9-d206-5213-01a9-f3ff4bf8b6d6
项目中有多个namespace bud = boost::units::degree;
定义导致了问题。将其从Equatorial_coord.hpp
中删除会为您带来魔力。
相关文章:
- 在使用 GCC 4.8.5 构建的应用中对 cxx11 函数的未定义引用
- 无法使用 devtoolsets-8-gcc 构建提升?
- 使用 CMake (make) 和 GCC 构建和编译 gSOAP 项目
- 使用 gcc 6 构建 OpenJDK8 时出现链接错误
- 使用 CodeBlocks + GCC 构建的可执行文件是否可以在任何 Windows 上运行?
- 使用GCC 4.8构建错误:数组用作初始化器
- 无法在 Windows 7、32 位上使用 tdm-gcc 构建 cpp 文件(表示 exe 不兼容)
- 如何在Windows上为GCC构建curlpp
- GCC 构建时间不会从预编译标头中受益太多
- 无法使用 GCC 构建 C 应用程序,因为未定义对'deflateEnd'的引用
- 用于回归测试的快速 GCC 构建
- gcc 4.7.1构建以未定义的引用结束
- GCOV:使用GCC构建时,覆盖率和最新覆盖率之间的区别是什么
- 使用从导入库(.lib)转换的库文件(.a),使用gcc构建dll
- 使用gcc构建poco时,Recipe失败
- 在Windows 7上使用Cygwin为GCC构建提升 - 引导错误
- 树莓派 GCC 4.8.2 构建提升 1.56 原子错误
- 静态初始化期间将 gcc 构建的 Boost 链接到英特尔 C++ 编译程序时出现 Segfault
- 使用GCC 5.2.0构建Chromium: - strict-overflow=1警告
- 在Xcode中使用gcc构建时,如何删除不需要的命令行选项?