我是c++和SWIG的新手
我正在windows环境中使用SWIG创建一个python模块。
创建包装类(例如wrap.cxx)之后。开始使用(python setup.py build_ext--inplace)创建python模块。
但是我得到了*example_wrap.cxx(3090):error c262:type'int'unexpected*
等级复杂.h:class GradedComplex
{
public:
typedef std::complex dcomplex;
typedef Item item_type;
typedef ItemComparator comparator;
typedef std::set grade_type;
private:
int n_;
std::vector grade_;
std::vector thre_;
public:
GradedComplex(int n, double *thre);
~GradedComplex();
void push(item_type item);
void avg(double *buf);
};
#endif
GradedComplex.cc级GradedComplex::GradedComplex(int n, double *thre)
{
n_ = n;
for (int i = 0; i < n_; ++i)
{
thre_.push_back(thre[i]);
grade_.push_back(new grade_type());
}
}
然后我使用SWIG构建它来生成python模块。
Swig接口文件(example.i)
GradedComplex(整数n,双*thre)
我对SWIG接口文件不是很在行
生成的包装器类有大量代码,因此我粘贴的代码很少。
代码:example_wrap.cxx3083: #define SWIG_FILE_WITH_INIT
3084: #include "Item.h"
3085: #include "GradedComplex.h"
3086: typedef std::complex dcomplex;
3087: typedef Item item_type;
3088: typedef ItemComparator comparator;
3089: typedef std::set grade_type;
3090: GradedComplex(int n, double *thre);
3091: void push(item_type item);
3092: void avg(double *buf);
3093: #include
3094: #include
3095: #include
3096: #if PY_VERSION_HEX >= 0x03020000
3097: # define SWIGPY_SLICE_ARG(obj) ((PyObject*) (obj))
3098: #else
3099: # define SWIGPY_SLICE_ARG(obj) ((PySliceObject*) (obj))
3100: #endif
GradedComplex构造函数:GradedComplex::GradedComplex(int n, double *thre)
{
n_ = n;
for (int i = 0; i < n_; ++i)
{
thre_.push_back(thre[i]);
grade_.push_back(new grade_type());
}
}
请建议a更正此错误