简体   繁体   中英

Compilation error after including jsoncpp

When I try to build test sources I get an error like after this.

stl_tree.h:542:14: error: '__node' does not name a type ::new(__node) _Rb_tree_node<_Val>;

Executor's content.

#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);
}

My test' s source code starts with below 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() { }
};

And the "common/data_util_astro_cfg.h" file has following includes.

#include "../data/data_type_file.h"
#include <json/json.h>

static AstroConfigs toAstroConfigs(std::string content)

My problem is I get compilation error with these includes, when I remove line json.h include everything is fine I can get binary output.

I think the problem is about new operator' s conflict. The solution is offered by Cpputest side and it is located on http://cpputest.github.io/manual.html#memory_leak_detection . But it isn't clear somehow. :(

The question has been already defined on Compilation error after including <map> . It is so similar to mine but the problem has solved with creating new project. In that case I have no option for that. I'm using Yocto project and the project has created with auto generation tools as well.

Can you help me on this? (Thank you for your time.)

Unfortunately, I solved the problem after a while. It seems something wrong with CPPUTest. At the top of the test file, I have several includes. Some of them belong to CPPUTest library, some of them are mine. My includes are following CPPUTest that's why I'm getting an error. If I changed their places, it would be working correctly. It seems meaningless, but it is the correct solution. ”PROBLEM SHOULD BE RESOLVED WITH DEFINE CPPUTEST LIBRARIES AT THE BOTTOM OF YOUR INCLUDE LIST.”

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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