私はc ++とSWIGが初めてです
Windows環境でSWIGを使用してpythonモジュールを作成しています。
ラッパー クラス (example_wrap.cxx) を作成した後。Pythonモジュールの作成に(python setup.py build_ext --inplace)を使用してビルドを開始しました。
しかし、私は*example_wrap.cxx(3090) : エラー C2062: タイプ 'int' 予期しない*を取得しています
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 モジュールを生成するためにビルドします。
Swig インターフェイス ファイル (example.i) GradedComplex(int n, double *thre);
私はSWIGインターフェースファイルの専門家ではありません
生成されたラッパー クラスには大量のコードがあるため、いくつか貼り付けています。
コード: 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());
}
}
このエラーを修正することを提案してください