简体   繁体   English

交叉编译错误Visual Studio C ++

[英]Cross-compilation errors Visual studio C++

I recently converted my Windows C++ application to a Linux c++ application and use a Windows subsystem with Debian to cross-compile to Linux. 最近,我将Windows C ++应用程序转换为Linux c ++应用程序,并使用Windows子系统和Debian交叉编译到Linux。 However, I get the following error by using the json library by nlohmann 但是,我通过使用nlohmann的json库得到以下错误

no match for 'operator-' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<double> >::value_type {aka double}' and 'nlohmann::basic_json<>::value_type {aka nlohmann::basic_json<>}')

I get this error everywhere where I use an operator between a json element and a double for example. 到处都遇到这个错误,例如在json元素和double之间使用运算符。 As an example: 举个例子:

MSE_total += pow(ref.z[j*multiplier] - actual[j]["z"], 2) / pow(ref.z[j*multiplier], 2);

This is the line that gives the error above. 这是给出上述错误的行。 Should I explicitely state what type of variable is in the json? 我是否应该明确声明json中的变量类型? And how do I do this? 我该怎么做?

There's no operator- taking a nlohmann::basic_json . 没有operator-使用nlohmann::basic_json I guess then that 我想那

ref.z[j*multiplier] - actual[j]["z"]

expects actual[j]["z"] to be converted to double via its operator ValueType() ... and it should (throwing type_error.302 in case of underlying type mismatch). 期望将type_error.302 actual[j]["z"]通过其operator ValueType()转换为double ,并且应该转换(如果基础类型不匹配,则抛出type_error.302 )。

Why it doesn't? 为什么不呢? My bet is on nlohmann's json version number differing from your windows and linux builds. 我敢打赌,nlohmann的json版本号与您的Windows和Linux版本不同。

Workaround: cast that value to a double ( actual[j]["z"].get<double>() ). 解决方法: 将该值转换为双精度actual[j]["z"].get<double>() )。

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

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