使用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
答案 0 :(得分: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 ++模板搜索结果的老鼠窝后,我有点不安,这是一个很容易解决的问题:)