【问题标题】:boost bind.hpp 1.54 c++ specialized template doesn't compile on Solaris. Valid C++?boost bind.hpp 1.54 c++ 专用模板不能在 Solaris 上编译。有效的 C++?
【发布时间】:2013-10-16 08:43:16
【问题描述】:

使用 Sun Studio 编译器为 Solaris 10 SPARC 编译 Phusion Passenger 时,在包含的 boost 1.54 头文件中会出现这些错误。怎么改写才能解决编译错误?

"ext/boost/bind/bind.hpp", line 69: Error: boost::_bi::F is not a namespace or class name.
"ext/boost/bind/bind_template.hpp", line 15:     Where: While specializing
"boost::_bi::result_traits<boost::_bi::unspecified, extern "C" int(*)(DIR*)>".
"ext/boost/bind/bind_template.hpp", line 15:     Where: Specialized in
boost::_bi::bind_t<boost::_bi::unspecified, extern "C" int(*)(DIR*), boost::_bi::list1<boost::_bi::value<DIR*>>>.
"ext/common/ApplicationPool2/Spawner.h", line 250:     Where: Specialized in non-template code.
"ext/boost/bind/bind.hpp", line 69: Error: result_type is not defined.
"ext/boost/bind/bind_template.hpp", line 15:     Where: While specializing "boost::_bi::result_traits<boost::_bi::unspecified, extern "C" int(*)(DIR*)>".
"ext/boost/bind/bind_template.hpp", line 15:     Where: Specialized in boost::_bi::bind_t<boost::_bi::unspecified, extern "C" int(*)(DIR*), boost::_bi::list1<boost::_bi::value<DIR*>>>.
"ext/common/ApplicationPool2/Spawner.h", line 250:     Where: Specialized in non-template code.

有问题的代码在这里:

56  // result_traits
57
58  template<class R, class F> struct result_traits
59  {
60      typedef R type;
61  };
62
63  #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
64
65  struct unspecified {};
66
67  template<class F> struct result_traits<unspecified, F>
68  {
69      typedef typename F::result_type type;
70  };
71
72  template<class F> struct result_traits< unspecified, reference_wrapper<F> >
73  {
74      typedef typename F::result_type type;
75  };
76
77  #endif

升压故障单: https://svn.boost.org/trac/boost/ticket/9250

boost bind.hpp 源代码: http://www.boost.org/doc/libs/1_54_0/boost/bind/bind.hpp

Phusion 乘客跟踪问题: https://code.google.com/p/phusion-passenger/issues/detail?id=982

【问题讨论】:

    标签: c++ boost solaris template-specialization


    【解决方案1】:

    来自https://svn.boost.org/trac/boost/ticket/9250

    "ext/common/ApplicationPool2/Spawner.h", line 250 should contain something like
    boost::bind(closedir, ...). It needs to be changed to
    boost::bind<int>(closedir, ...). The problem is that on this compiler extern "C"
    functions are distinct from ordinary C++ functions.
    

    http://www.boost.org/doc/libs/1_54_0/libs/bind/bind.html#Q_extern_C

    在昨天追逐 C++ 模板搜索结果的老鼠窝之后,我有点不安,解决起来这么容易:)

    【讨论】:

      猜你喜欢
      • 2013-09-15
      • 1970-01-01
      • 2011-03-05
      • 2017-06-17
      • 1970-01-01
      • 2013-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多