boost :: shared_ptr.hpp中的错误

时间:2015-03-08 11:51:10

标签: c++ boost

我正在尝试编译使用Boost库1.57的程序。在Debian Jessie 64bit上它没有问题,但在Debian Squeeze 64bit上显示以下错误:

In file included from /usr/local/include/boost/detail/sp_typeinfo.hpp:20:0,
                 from /usr/local/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:27,
                 from /usr/local/include/boost/smart_ptr/detail/sp_counted_base.hpp:42,
                 from /usr/local/include/boost/smart_ptr/detail/shared_count.hpp:29,
                 from /usr/local/include/boost/smart_ptr/shared_ptr.hpp:28,
                 from /usr/local/include/boost/shared_ptr.hpp:17,
                 from core.h:40,
                 from ai.cpp:1:
/usr/local/include/boost/core/typeinfo.hpp:138:51: error: ‘boost::{anonymous}::demangled_name’ declared as an ‘inline’ variable
 inline std::string demangled_name( core::typeinfo const & ti )
                                                   ^
/usr/local/include/boost/core/typeinfo.hpp:138:40: error: ‘::typeinfo’ has not been declared
 inline std::string demangled_name( core::typeinfo const & ti )
                                        ^
/usr/local/include/boost/core/typeinfo.hpp:138:40: note: suggested alternatives:
/usr/local/include/boost/core/typeinfo.hpp:134:24: note:   ‘boost::{anonymous}::typeinfo’
 typedef std::type_info typeinfo;
                        ^
/usr/local/include/boost/core/typeinfo.hpp:134:24: note:   ‘boost::{anonymous}::typeinfo’
/usr/local/include/boost/core/typeinfo.hpp:139:1: error: expected ‘,’ or ‘;’ before ‘{’ token
 {
 ^
In file included from /usr/local/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:27:0,
                 from /usr/local/include/boost/smart_ptr/detail/sp_counted_base.hpp:42,
                 from /usr/local/include/boost/smart_ptr/detail/shared_count.hpp:29,
                 from /usr/local/include/boost/smart_ptr/shared_ptr.hpp:28,
                 from /usr/local/include/boost/shared_ptr.hpp:17,
                 from core.h:40,
                 from ai.cpp:1:
/usr/local/include/boost/detail/sp_typeinfo.hpp:28:20: error: expected unqualified-id before ‘::’ token
 typedef boost::core::typeinfo sp_typeinfo;
                    ^
In file included from /usr/local/include/boost/smart_ptr/detail/sp_counted_base.hpp:42:0,
                 from /usr/local/include/boost/smart_ptr/detail/shared_count.hpp:29,
                 from /usr/local/include/boost/smart_ptr/shared_ptr.hpp:28,
                 from /usr/local/include/boost/shared_ptr.hpp:17,
                 from core.h:40,
                 from ai.cpp:1:
/usr/local/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:129:45: error: ‘get_deleter’ declared as a ‘virtual’ field
     virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
                                             ^
/usr/local/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:129:20: error: expected ‘;’ at end of member declaration
     virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
                    ^
/usr/local/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:129:45: error: expected ‘)’ before ‘const’
     virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
                                             ^
In file included from /usr/local/include/boost/smart_ptr/detail/shared_count.hpp:30:0,
                 from /usr/local/include/boost/smart_ptr/shared_ptr.hpp:28,
                 from /usr/local/include/boost/shared_ptr.hpp:17,
                 from core.h:40,
                 from ai.cpp:1:
/usr/local/include/boost/smart_ptr/detail/sp_counted_impl.hpp:81:53: error: ‘get_deleter’ declared as a ‘virtual’ field
     virtual void * get_deleter( detail::sp_typeinfo const & )
                                                     ^
/usr/local/include/boost/smart_ptr/detail/sp_counted_impl.hpp:81:20: error: expected ‘;’ at end of member declaration
     virtual void * get_deleter( detail::sp_typeinfo const & )
                    ^
/usr/local/include/boost/smart_ptr/detail/sp_counted_impl.hpp:81:53: error: expected ‘)’ before ‘const’
     virtual void * get_deleter( detail::sp_typeinfo const & )
                                                     ^
/usr/local/include/boost/smart_ptr/detail/sp_counted_impl.hpp:156:53: error: ‘get_deleter’ declared as a ‘virtual’ field
     virtual void * get_deleter( detail::sp_typeinfo const & ti )
                                                     ^
/usr/local/include/boost/smart_ptr/detail/sp_counted_impl.hpp:156:20: error: expected ‘;’ at end of member declaration
     virtual void * get_deleter( detail::sp_typeinfo const & ti )
                    ^
/usr/local/include/boost/smart_ptr/detail/sp_counted_impl.hpp:156:53: error: expected ‘)’ before ‘const’
     virtual void * get_deleter( detail::sp_typeinfo const & ti )
                                                     ^
/usr/local/include/boost/smart_ptr/detail/sp_counted_impl.hpp:252:53: error: ‘get_deleter’ declared as a ‘virtual’ field
     virtual void * get_deleter( detail::sp_typeinfo const & ti )
                                                     ^
/usr/local/include/boost/smart_ptr/detail/sp_counted_impl.hpp:252:20: error: expected ‘;’ at end of member declaration
     virtual void * get_deleter( detail::sp_typeinfo const & ti )
                    ^
/usr/local/include/boost/smart_ptr/detail/sp_counted_impl.hpp:252:53: error: expected ‘)’ before ‘const’
     virtual void * get_deleter( detail::sp_typeinfo const & ti )
                                                     ^
In file included from /usr/local/include/boost/smart_ptr/shared_ptr.hpp:28:0,
                 from /usr/local/include/boost/shared_ptr.hpp:17,
                 from core.h:40,
                 from ai.cpp:1:
/usr/local/include/boost/smart_ptr/detail/shared_count.hpp:518:12: error: expected ‘;’ at end of member declaration
     void * get_deleter( sp_typeinfo const & ti ) const
            ^
/usr/local/include/boost/smart_ptr/detail/shared_count.hpp:518:37: error: expected ‘)’ before ‘const’
     void * get_deleter( sp_typeinfo const & ti ) const
                                     ^
In file included from /usr/local/include/boost/shared_ptr.hpp:17:0,
                 from core.h:40,
                 from ai.cpp:1:
/usr/local/include/boost/smart_ptr/shared_ptr.hpp:695:12: error: expected ‘;’ at end of member declaration
     void * _internal_get_deleter( boost::detail::sp_typeinfo const & ti ) const BOOST_NOEXCEPT
            ^
/usr/local/include/boost/smart_ptr/shared_ptr.hpp:695:62: error: expected ‘)’ before ‘const’
     void * _internal_get_deleter( boost::detail::sp_typeinfo const & ti ) const BOOST_NOEXCEPT
                                                              ^
make: *** [ai.o] Error 1

在我的文件core.h的程序行40中只是:

#include <boost/shared_ptr.hpp>

我用g ++ 4.9.2编译它(带有标志std = c ++ 11)。

我认为Boost安装正确,因为当我运行&#34; ./ b2 install&#34;它没有显示任何失败的目标。

  • 你知道可能出了什么问题吗?

1 个答案:

答案 0 :(得分:0)

所以我发现我有头球卫士:

#ifndef core
#define core

删除或重命名这已解决了这个问题。