我刚开始使用C ++,试图学习一些基础知识。现在正在Eclipse中使用gcc版本5.2.1进行编译,项目是用c ++ 11参数编译的。
现在当我尝试#include <map>
时会出现包含问题(只要编译器进入它就没关系,我甚至不使用map,只是试图包含它)。据我所知,地图本身存在问题,但似乎并不正确。这里有短暂的故障片段。
08:54:59 **** Incremental Build of configuration Debug for project RpnCalculator ****
make all
Building file: ../Test/AddShouldBeRegistered.cpp
Invoking: Cross G++ Compiler
g++ -I/home/yoger/Coding/cpputest/include -O0 -g3 -Wall -c -fmessage- length=0 -std=c++11 -v -MMD -MP -MF"Test/AddShouldBeRegistered.d" -MT"Test/AddShouldBeRegistered.d" -o "Test/AddShouldBeRegistered.o" "../Test/AddShouldBeRegistered.cpp"
Using built-in specs.
COLLECT_GCC=g++
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.2.1-22ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2)
COLLECT_GCC_OPTIONS='-I' '/home/yoger/Coding/cpputest/include' '-O0' '-g3' '-Wall' '-c' '-fmessage-length=0' '-std=c++11' '-v' '-MMD' '-MP' '-MF' 'Test/AddShouldBeRegistered.d' '-MT' 'Test/AddShouldBeRegistered.d' '-o' 'Test/AddShouldBeRegistered.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/5/cc1plus -quiet -v -I /home/yoger/Coding/cpputest/include -imultiarch x86_64-linux-gnu -MMD Test/AddShouldBeRegistered.d -MF Test/AddShouldBeRegistered.d -MP -MT Test/AddShouldBeRegistered.d -dD -D_GNU_SOURCE ../Test/AddShouldBeRegistered.cpp -quiet -dumpbase AddShouldBeRegistered.cpp -mtune=generic -march=x86-64 -auxbase-strip Test/AddShouldBeRegistered.o -g3 -O0 -Wall -std=c++11 -version -fmessage-length=0 -fstack-protector-strong -Wformat-security -o /tmp/cc8xNfBA.s
GNU C++11 (Ubuntu 5.2.1-22ubuntu2) version 5.2.1 20151010 (x86_64-linux-gnu)
compiled by GNU C version 5.2.1 20151010, GMP version 6.0.0, MPFR version 3.1.3, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/5"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/home/yoger/Coding/cpputest/include
/usr/include/c++/5
/usr/include/x86_64-linux-gnu/c++/5
/usr/include/c++/5/backward
/usr/lib/gcc/x86_64-linux-gnu/5/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
GNU C++11 (Ubuntu 5.2.1-22ubuntu2) version 5.2.1 20151010 (x86_64-linux-gnu)
compiled by GNU C version 5.2.1 20151010, GMP version 6.0.0, MPFR version 3.1.3, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 5ed623d6fe11f4bcc1afee70f77e33b0
In file included from /usr/include/c++/5/map:60:0,
from ../Test/../MathOperations/MathOperationFactory.h:11,
from ../Test/ShouldBeRegistered.h:13,
from ../Test/AddShouldBeRegistered.cpp:9:
/usr/include/c++/5/bits/stl_tree.h: In member function ‘void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_construct_node(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type, _Args&& ...)’:
/usr/include/c++/5/bits/stl_tree.h:528:14: error: ‘__node’ does not name a type
::new(__node) _Rb_tree_node<_Val>;
^
Test/subdir.mk:66: recipe for target 'Test/AddShouldBeRegistered.o' failed
make: *** [Test/AddShouldBeRegistered.o] Error 1
08:54:59 Build Finished (took 361ms)
好的,我包含地图的文件
#ifndef MATHOPERATIONFACTORY_H_
#define MATHOPERATIONFACTORY_H_
#include <map>
#include <string>
class MathOperation;
class MathOperationFactory {
public:
MathOperationFactory();
virtual ~MathOperationFactory();
virtual MathOperation& findOperationNamed(const std::string &name);
private:
typedef std::map<std::string, MathOperation*> OperationMap;
typedef OperationMap::iterator iterator;
OperationMap _operationsByName;
};
#endif
答案 0 :(得分:1)
这是与Cpputest的内存泄漏检测功能相关的问题。您可以应用Cpputest文档页面中描述的解决方案之一。
答案 1 :(得分:0)
所以我没有找到确切的答案,但设法通过简单地将所有项目文件移动到新项目来完全解决问题。 这意味着问题在某种程度上与项目设置有关,我比较了两个项目的编译器设置,它们是相同的,所以原因仍然是非常精细的钻石硬雾层。