交叉编译错误 Visual Studio C++
Cross-compilation errors Visual studio C++
我最近将我的Windows C++应用程序转换为Linux c ++应用程序,并使用带有Debian的Windows子系统交叉编译到Linux。但是,我通过使用 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<>}')
例如,我在 json 元素和双精度之间使用运算符的任何地方都会遇到此错误。举个例子:
MSE_total += pow(ref.z[j*multiplier] - actual[j]["z"], 2) / pow(ref.z[j*multiplier], 2);
这是给出上述错误的行。我应该明确说明 json 中的变量类型吗?我该怎么做呢?
没有
operator-
采取nlohmann::basic_json
。我猜那
ref.z[j*multiplier] - actual[j]["z"]
希望actual[j]["z"]
通过其operator ValueType()
转换为double
...它应该(在底层类型不匹配的情况下抛出type_error.302
(。
为什么没有?我打赌nlohmann的json版本号与Windows和Linux版本不同。
解决办法:将该值强制转换为双精度型 ( actual[j]["z"].get<double>()
(。
相关文章:
- Visual Studio 2015:Extern "C" 和 "export" 关键字
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 试图在visual studio上用C++创建一个桌面应用程序
- 如何在MS Visual Studio 2019中运行QT UI
- 如何使用Visual Studio 2017在C++中为参数化对象数组使用唯一指针
- Visual Studio Code - C++ Debugger 無法啟動
- Visual Studio 2019:插入多个C++风格的单行注释
- Visual Studio Code "undefined reference to `WinMain@16'"
- Visual studio代码重构似乎不起作用(例如,重命名符号-f2)
- Visual Studio中的函数声明和函数定义问题
- 如何指定我希望我的LIB链接到的DLL文件?-Visual Studio 2019
- Visual Studio mkl_link_tool.exe链接错误
- Visual Studio(或任何其他工具)能否将地址解释为调用堆栈(boost上下文)的开头
- 不同的Visual Studio版本中缺少.dll
- 用Visual Studio在C++中嵌入Julia
- Visual Studio 2017循环自动向量化问题
- 有没有办法在远程设备上打开和编辑visual Studio 2017解决方案
- 尝试使用继承和模板实现CRTP.Visual Studio正在生成编译器错误
- Visual Studio在尝试读取resource.txt文件时崩溃
- Visual Studio 2017 不允许我创建 C++ 专用模板