c++ - 包含 jsoncpp 后编译错误
问题描述
当我尝试构建测试源时,我得到一个类似的错误。
stl_tree.h:542:14: 错误: '__node' 没有命名类型 ::new(__node) _Rb_tree_node<_Val>;
执行者的内容。
#include <CppUTest/TestHarness.h>
#include <CppUTest/CommandLineTestRunner.h>
#include <CppUTest/UtestMacros.h>
#include <CppUTestExt/MockSupport.h>
int main(int argc, char** argv) {
MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
return CommandLineTestRunner::RunAllTests(argc, argv);
}
我的测试的源代码以以下包括开头。
#include <CppUTest/TestHarness.h>
#include <CppUTest/CommandLineTestRunner.h>
#include <CppUTest/UtestMacros.h>
#include <CppUTestExt/MockSupport.h>
#include <iostream>
#include "common/data_util_astro_cfg.h"
TEST_GROUP(ASTRO_UTIL_TEST) {
void setup() { }
void teardown() { }
};
“common/data_util_astro_cfg.h”文件包含以下内容。
#include "../data/data_type_file.h"
#include <json/json.h>
static AstroConfigs toAstroConfigs(std::string content)
我的问题是我得到了这些包含的编译错误,当我删除行 json.h include 一切都很好我可以获得二进制输出。
我认为问题在于新运营商的冲突。该解决方案由 Cpputest 方提供,位于http://cpputest.github.io/manual.html#memory_leak_detection。但不知何故还不清楚。:(
包含 <map> 后,该问题已在编译错误中定义。它与我的非常相似,但问题已通过创建新项目解决。在那种情况下,我别无选择。我正在使用 Yocto 项目,该项目也使用自动生成工具创建。
你能帮我解决这个问题吗?(感谢您的时间。)
解决方案
不幸的是,我在一段时间后解决了这个问题。CPPUTest 似乎有问题。在测试文件的顶部,我有几个包含。其中一些属于 CPPUTest 库,其中一些是我的。我的包含在 CPPUTest 之后,这就是我收到错误的原因。如果我改变他们的位置,它将正常工作。这似乎毫无意义,但却是正确的解决方案。“应该通过在包含列表底部定义 CPPUTEST 库来解决问题。”</p>
推荐阅读
- mongodb - 将 mongodb docker 容器连接到 localhost
- javascript - 返回没有引用的javascript函数
- ios - 尝试使用 CALayers 为水龙头的水滴设置动画
- android - 网格布局android无法正常工作?
- image - 可以删除“user-images.githubusercontent.com”上的图像吗?
- node.js - TypeError:无法读取未定义的属性“ImageAnnotatorClient”
- firebase - Cloud Firestore 安全规则 - 访问对象数组中的属性
- go - golang 使用 duosecurity 获取命令
- algorithm - 优化 Modbus 请求
- asp.net-mvc - 会话中还有其他线程正在运行