包含jsoncpp之后的编译错误

时间:2019-02-09 22:04:35

标签: c++

当我尝试构建测试源时,会收到类似下面的错误。

  

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时,包括一切都很好,我可以得到二进制输出。

我认为问题在于新运营商的冲突。该解决方案由Cpputest一方提供,位于http://cpputest.github.io/manual.html#memory_leak_detection上。但目前尚不清楚。 :(

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

您能帮我吗? (谢谢您的时间。)

1 个答案:

答案 0 :(得分:1)

不幸的是,一段时间后我解决了这个问题。 CPPUTest似乎有问题。在测试文件的顶部,我有几个包含项。其中一些属于CPPUTest库,其中一些属于我。我的收录者关注的是CPPUTest,这就是为什么我遇到错误。如果我更改了他们的位置,它将可以正常工作。似乎没有意义,但这是正确的解决方案。 “应该在清单的底部使用定义明确的提案库解决该问题。”