gpt4 book ai didi

c++ - 包含jsoncpp后的编译错误

转载 作者:搜寻专家 更新时间:2023-10-31 02:03:55 27 4
gpt4 key购买 nike

当我尝试构建测试源时,我收到类似此后的错误。

stl_tree.h:542:14: error: ‘__node’ does not name a type ::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);
}

我的测试源代码以下面的 includes 开头。

#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。 .但不知何故还不清楚。 :(

问题已在 Compilation error after including <map> 上定义.它与我的非常相似,但问题已通过创建新项目解决。在那种情况下,我别无选择。我正在使用 Yocto 项目,该项目也是使用自动生成工具创建的。

你能帮我解决这个问题吗? (感谢您的宝贵时间。)

最佳答案

不幸的是,我在一段时间后解决了这个问题。 CPPUTest 似乎有问题。在测试文件的顶部,我有几个包含。其中一些属于 CPPUTest 库,一些是我的。我的包含在 CPPUTest 之后,这就是我收到错误的原因。如果我改变他们的位置,它就会正常工作。看似毫无意义,却是正确的解决方法。 “问题应该通过在包含列表的底部定义 CPPUTEST 库来解决。”

关于c++ - 包含jsoncpp后的编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54611227/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com