は例えば、私はtest.cpp
を持っている:SWIGインターフェイスファイルの書き込み方法は?
#include<iostream>
using namespace std;
void hello(){
cout<<"Hello World!"<<endl;
}
私はtest.i
を書く:
%module test
%{
#include<iostream>
%}
void hello();
私はtest_wrap.cxxをコンパイルすると、それは私にhello() is not declare
を言うと、私はtest.i
を変更:
%module test
%{
#include<iostream>
void hello();
%}
void hello();
コンパイルに合格しましたが、私は混乱しています。私はいくつか見るのでdemos関数宣言を%{
%{
に記述しないでください。なぜ、 void hello();
を2回書く必要がありますか?
インタフェースファイル内の関数を手動で宣言するのではなく、ヘッダファイルを '%include'することをお勧めします(http://www.swig.org/Doc3.0/SWIGDocumentation.html#SWIG_nn46)。それはあなたのために働かないのですか? – Melebius