我是新來的C++和SWIG錯誤C2062:鍵入int意外
我在Windows環境中使用SWIG創建一個python模塊。
創建包裝類(example_wrap.cxx)後。開始使用(python setup.py build_ext --inplace)創建python模塊。
但我得到* example_wrap.cxx(3090):錯誤C2062:類型 '詮釋' 意外*
GradedComplex.h:
class GradedComplex
{
public:
typedef std::complex<double> dcomplex;
typedef Item<dcomplex> item_type;
typedef ItemComparator<dcomplex> comparator;
typedef std::set<item_type, comparator> grade_type;
private:
int n_;
std::vector<grade_type *> grade_;
std::vector<double> 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模塊。 Swing接口文件(example.i) GradedComplex(int n,double * thre);
我不是痛飲接口文件
產生的包裝類有大量的代碼更專業,所以我粘貼一些。
代碼:example_wrap.cxx
3083: #define SWIG_FILE_WITH_INIT
3084: #include "Item.h"
3085: #include "GradedComplex.h"
3086: typedef std::complex<double> dcomplex;
3087: typedef Item<dcomplex> item_type;
3088: typedef ItemComparator<dcomplex> comparator;
3089: typedef std::set<item_type, comparator> grade_type;
3090: GradedComplex(int n, double *thre);
3091: void push(item_type item);
3092: void avg(double *buf);
3093: #include <string>
3094: #include <complex>
3095: #include <iostream>
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());
}
}
請提出一個糾正這個錯誤
3102行仍然丟失。 –
@KirillKobelev這是一個錯誤。抱歉給你帶來不便 。我已糾正它。 –
GradedComplex(int n,double * thre);沒有返回類型。 – imreal