boost / smart_ptr构建错误

时间:2016-12-08 09:22:12

标签: c++ gcc boost g++

当我尝试构建非常陈旧的代码时,我遇到了一些错误 “<升压/ smart_ptr.hpp>” 中。

    In file included from /usr/include/boost/shared_array.hpp:17:0,
                 from /usr/include/boost/smart_ptr.hpp:22,
                 from ../para/SSParameters.h:19,
                 from SSShmooTestAnalyzer.cpp:10:
/usr/include/boost/smart_ptr/shared_array.hpp:83:66: error: 'a' has not been declared
     template<class Y, class D, class A> shared_array( Y * p, D d, A a ): px( p ), pn( p, d, a )
                                                                  ^
In file included from /usr/include/boost/shared_array.hpp:17:0,
                 from /usr/include/boost/smart_ptr.hpp:22,
                 from ../para/SSParameters.h:19,
                 from SSShmooTestAnalyzer.cpp:10:
/usr/include/boost/smart_ptr/shared_array.hpp:182:64: error: 'a' has not been declared
     template<class Y, class D, class A> void reset( Y * p, D d, A a )
                                                                ^
In file included from /usr/include/boost/shared_array.hpp:17:0,
                 from /usr/include/boost/smart_ptr.hpp:22,
                 from ../para/SSParameters.h:19,
                 from SSShmooTestAnalyzer.cpp:10:
/usr/include/boost/smart_ptr/shared_array.hpp: In constructor 'boost::shared_array<T>::shared_array(Y*, D, int)':
/usr/include/boost/smart_ptr/shared_array.hpp:83:90: error: 'a' was not declared in this scope

         template<class Y, class D, class A> shared_array( Y * p, D d, A a ): px( p ), pn( p, d, a )
                                                                                              ^
    In file included from /usr/include/boost/shared_array.hpp:17:0,
                     from /usr/include/boost/smart_ptr.hpp:22,
                     from ../para/SSParameters.h:19,
                     from SSShmooTestAnalyzer.cpp:10:
    /usr/include/boost/smart_ptr/shared_array.hpp: In member function 'void boost::shared_array<T>::reset(Y*, D, int)':
    /usr/include/boost/smart_ptr/shared_array.hpp:184:26: error: 'a' was not declared in this scope
             this_type( p, d, a ).swap( *this );
                              ^

在allocate_shared_array.hpp中也存在一些错误

In file included from /usr/include/boost/smart_ptr/make_shared.hpp:19:0,
                 from /usr/include/boost/make_shared.hpp:15,
                 from /usr/include/boost/smart_ptr.hpp:28,
                 from SSEMAP.h:14,
                 from SSDomainResult.h:20,
                 from SSResultAnalyzerFactory.h:14,
                 from SSResultAnalyzerFactory.cpp:8:
/usr/include/boost/smart_ptr/allocate_shared_array.hpp: In function 'typename boost::detail::sp_if_array<T>::type boost::allocate_shared_noinit(const int&, std::size_t)':
/usr/include/boost/smart_ptr/allocate_shared_array.hpp:220:52: error: template argument 1 is invalid
         boost::detail::allocate_array_helper<A, T2[]> a1(allocator, n1, &p2);
                                                    ^
/usr/include/boost/smart_ptr/allocate_shared_array.hpp:220:56: error: invalid type in declaration before '(' token
         boost::detail::allocate_array_helper<A, T2[]> a1(allocator, n1, &p2);
                                                        ^
/usr/include/boost/smart_ptr/allocate_shared_array.hpp:220:75: error: expression list treated as compound expression in initializer [-fpermissive]
         boost::detail::allocate_array_helper<A, T2[]> a1(allocator, n1, &p2);
                                                                           ^
/usr/include/boost/smart_ptr/allocate_shared_array.hpp: In function 'typename boost::detail::sp_if_size_array<T>::type boost::allocate_shared_noinit(const int&)':
/usr/include/boost/smart_ptr/allocate_shared_array.hpp:239:53: error: template argument 1 is invalid
         boost::detail::allocate_array_helper<A, T2[N]> a1(allocator, &p2);
                                                     ^
/usr/include/boost/smart_ptr/allocate_shared_array.hpp:239:57: error: invalid type in declaration before '(' token
         boost::detail::allocate_array_helper<A, T2[N]> a1(allocator, &p2);
                                                         ^
/usr/include/boost/smart_ptr/allocate_shared_array.hpp:239:72: error: expression list treated as compound expression in initializer [-fpermissive]
         boost::detail::allocate_array_helper<A, T2[N]> a1(allocator, &p2);
                                                                        ^

我无法理解为什么它会发布错误。

它可以在red hat 5中成功构建,并且提升1.33.1,gcc 4.1.2。

但它不能用red hat 7构建,并且提升1.53.0,gcc 4.8.2。

我知道环境与旧环境截然不同。但我也想尝试将其建立成功。最好在没有代码更改的情况下构建。

SSShmooTestAnalyzer.cpp没有关于boost和smart_ptr的代码。它只包含名为SSParameters.h的标题。

很抱歉,我无法向您展示有关我项目的所有代码。我可以向您展示一些关于boost和smart_ptr的代码。我应该展示更多东西吗?

SSParameters.h:

#include "tml_base.h"
#include "SSPara.h"
#include <boost/smart_ptr.hpp>
#include <assert.h>
#include <string>
#include <vector>


namespace sols
{
  class ITestSetControl;
}

using sols::ITestSetControl;
using std::vector;

namespace source_sync
{
  class CSSParameters
  {
  public:

............

    boost::shared_ptr<CSSEdgePara> &getEdgePara()
    {
      return mpEdgePara;
    }

    boost::shared_ptr<CSSTimingPara> &getTimingPara()
    {
      return mpTimingPara;
    }

    boost::shared_ptr<CSSResultPara> &getResultPara()
    {
      return mpResultPara;
    }

    const boost::shared_ptr<CSSResultPara> &getResultPara() const
    {
      return mpResultPara;
    }

    const boost::shared_ptr<ITestSetControl> &getTestSetControl() const
    {
      return mpTestSet;
    }

..........

 private:

.........

    boost::shared_ptr<CSSResultPara> mpResultPara;
    boost::shared_ptr<CSSEdgePara> mpEdgePara;
    boost::shared_ptr<CSSTimingPara> mpTimingPara;
    boost::shared_ptr<ITestSetControl> mpTestSet;

.......

 };
}

1 个答案:

答案 0 :(得分:0)

错误看起来像你错过了一个头文件中的右括号/括号/分号,它包含在boost头文件之前。