error: '__gnu_cxx::_Lock_policy' has not been declared
第一次开博客,不知道写什么好,随便记录一下今天遇见的问题吧。
第一次使用shared_ptr就出现了这个问题:
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:81:20: error: '__gnu_cxx::_Lock_policy' has not been declared
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:82:20: error: '__gnu_cxx::__default_lock_policy' has not been declared
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:83:20: error: '__gnu_cxx::_S_single' has not been declared
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:84:20: error: '__gnu_cxx::_S_mutex' has not been declared
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:85:20: error: '__gnu_cxx::_S_atomic' has not been declared
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:88:12: error: '_Lock_policy' has not been declared
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:97:23: error: '_S_mutex' was not declared in this scope
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:97:31: error: template argument 1 is invalid
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:99:5: error: expected class-name before '{' token
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:107:12: error: '_Lock_policy' has not been declared
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:107:31: error: '__default_lock_policy' was not declared in this scope
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:210:22: error: '_S_single' was not declared in this scope
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:210:31: error: template argument 1 is invalid
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:211:21: error: '_M_add_ref_lock' is not a template function
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:222:22: error: '_S_mutex' was not declared in this scope
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:222:30: error: template argument 1 is invalid
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:223:21: error: '_M_add_ref_lock' is not a template function
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:235:22: error: '_S_atomic' was not declared in this scope
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:235:31: error: template argument 1 is invalid
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:236:21: error: '_M_add_ref_lock' is not a template function
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:253:46: error: '_Lock_policy' has not been declared
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:284:12: error: '_Lock_policy' has not been declared
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:284:31: error: '__default_lock_policy' was not declared in this scope
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:295:12: error: '_Lock_policy' has not been declared
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:295:31: error: '__default_lock_policy' was not declared in this scope
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/tr1/shared_ptr.h:336:37: error: expected ')' before '<' token
上网搜了一下发现要include tr1/memory
加了以后还是无法编译
最后发现要把#include <tr1/memory>放在#include <tr1/shared_ptr.h>前面才行,真神奇……