1

使用 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

4

1 回答 1

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-10-16T00:43:16.747 回答