2 zh523 zh523 于 2016.01.25 23:08 提问

Linux 下编译C出错(windows编译正常)

Ubuntu 15
gcc version 5.2.1
错误:
图片说明

scritpt.hpp下是一个 命名空间
namespace script{
....
int setData( PyObject * pObj, Vector4 & rVal, const char * varName = "" );
int setData( PyObject * pObj, Matrix & rVal, const char * varName = "" );
int setData( PyObject * pObj, PyObject * & rVal,
const char * varName = "" );
int setData( PyObject * pObj, SmartPointer & rPyObject,
const char * varName = "" );
int setData( PyObject * pObj, Capabilities & rCaps,
const char * varName = "" );
int setData( PyObject * pObj, std::string & rString,
const char * varName = "" );
int setData( PyObject * pObj, std::wstring & rString,
const char * varName = "" );
int setData( PyObject * pObj, char * & rString,
const char * varName = "" );
int setData( PyObject * pObj, Mercury::Address & rAddr,
const char * varName = "" );

template <class T>
PyObject * getReadOnlyData( const T & d )
{
    return getData( d ); //出问题的地方126行
}

PyObject * getData( const bool data );
PyObject * getData( const int data );
PyObject * getData( const uint data );
....

}

stl_to_py.cpp
PyObject * Script::getData( const PySTLSequenceHolderBase & holder ) //出错位置
{
return new PySTLSequence(
const_cast(holder), holder.pOwner() );
}

stl_to_py.hpp 中
namespace Script
{
int setData( PyObject * pObject, PySTLSequenceHolderBase & data,
const char * varName = "" );

PyObject * getData( const PySTLSequenceHolderBase & data );

};

不知道哪里出错了,求大神指点

是有定义了的
定义在st_to_py.hpp中
note:
stl_to_py.cpp:506 'PyObjest * Script::getData(const PySTLSequenceHoldBase &) ' declared here ,later in the translation unit
PyObjest * Script::getData(const PySTLSequenceHoldBase & holder)

st_to_py.hpp 是 include了 script.hpp

这个在window环境下是能编译通过的

4个回答

qq_27183003
qq_27183003   Ds   Rxr 2016.01.25 23:32
已采纳

把声明放前面试试:

PyObject * getData( const bool data );
PyObject * getData( const int data );
PyObject * getData( const uint data );

 template <class T>
PyObject * getReadOnlyData( const T & d )
{
    return getData( d ); //出问题的地方126行
}


zh523
zh523 能说说愿意吗
接近 2 年之前 回复
qq_27183003
qq_27183003   Ds   Rxr 2016.01.25 23:29

从出错信息看:getData( d )未定义,检查一下看看吧,没看到定义部分。

xyz347
xyz347   2016.01.26 08:19

this->getData

Royal_lr
Royal_lr   Ds   Rxr 2016.01.26 13:40

方法未声明,,,,,

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!