如果使用自定义模板类,则对基类一无所知 我正试着把一个C++项目的LbSnAgk包到Galang. 我收到了以下警告: SWIG:1: Warning 125: Use of the include path to find the input file is deprecated and will not work with ccache. Please include the path when specifying the input file. ./go_wrapper/swig/../../libsnark/libsnark/gadgetlib2/variable.hpp:320: Warning 401: Nothing known about base class 'VariableArrayContents'. Ignored. ./go_wrapper/swig/../../libsnark/libsnark/gadgetlib2/variable.hpp:332: Warning 315: Nothing known about 'VariableArrayContents::operator []'. ./go_wrapper/swig/../../libsnark/libsnark/gadgetlib2/variable.hpp:333: Warning 315: Nothing known about 'VariableArrayContents::at'. 这里是C++片段 类变量{ /** *@brief分配变量 */ 公众: 显式变量(const::std::string&name=“”); 虚拟变量(); ... }; // 类变量 typedef::std::向量变量数组内容; 类VariableArray:公共VariableArray内容{ 公众: 使用VariableArrayContents::operator[]; 使用VariableArrayContents::at; 使用VariableArrayContents::push_back; 使用VariableArrayContents::size; ... }

如果使用自定义模板类,则对基类一无所知 我正试着把一个C++项目的LbSnAgk包到Galang. 我收到了以下警告: SWIG:1: Warning 125: Use of the include path to find the input file is deprecated and will not work with ccache. Please include the path when specifying the input file. ./go_wrapper/swig/../../libsnark/libsnark/gadgetlib2/variable.hpp:320: Warning 401: Nothing known about base class 'VariableArrayContents'. Ignored. ./go_wrapper/swig/../../libsnark/libsnark/gadgetlib2/variable.hpp:332: Warning 315: Nothing known about 'VariableArrayContents::operator []'. ./go_wrapper/swig/../../libsnark/libsnark/gadgetlib2/variable.hpp:333: Warning 315: Nothing known about 'VariableArrayContents::at'. 这里是C++片段 类变量{ /** *@brief分配变量 */ 公众: 显式变量(const::std::string&name=“”); 虚拟变量(); ... }; // 类变量 typedef::std::向量变量数组内容; 类VariableArray:公共VariableArray内容{ 公众: 使用VariableArrayContents::operator[]; 使用VariableArrayContents::at; 使用VariableArrayContents::push_back; 使用VariableArrayContents::size; ... },c++,go,swig,C++,Go,Swig,这是我的swig文件 %module gadgetlib2 %include <typemaps.i> %include "std_vector.i" %include "std_string.i" %ignore VariableArrayContents; typedef std::vector<Variable> VariableArrayContents; %{ typedef std::vector<Variable> VariableArra

这是我的swig文件

%module gadgetlib2

%include <typemaps.i>
%include "std_vector.i"
%include "std_string.i"


%ignore VariableArrayContents;
typedef std::vector<Variable> VariableArrayContents;
%{
typedef std::vector<Variable> VariableArrayContents;
%}
namespace std {
   %template(StringVector) vector<string>;
   %template(VariableArrayContentsVector) vector<Variable>;
   // Use this, got the same result 
   // %template(VariableArrayContentsVector) vector<Variable>;
}


%include "../../libsnark/libsnark/gadgetlib2/variable.hpp"
%include "../../libsnark/libsnark/gadgetlib2/variable_operators.hpp"
%include "../../libsnark/libsnark/gadgetlib2/protoboard.hpp"
%include "../../libsnark/libsnark/gadgetlib2/pp.hpp"
...
%lib2模块
%包括
%包括“标准向量i”
%包括“std_string.i”
%忽略可变的数组内容;
typedef std::向量变量数组内容;
%{
typedef std::向量变量数组内容;
%}
名称空间标准{
%模板(StringVector)向量;
%模板(VariableArrayContentsVector)向量;
//用这个,得到同样的结果
//%模板(VariableArrayContentsVector)向量;
}
%包括“../../libsnark/libsnark/gadgetlib2/variable.hpp”
%包括“../../libsnark/libsnark/gadgetlib2/variable_operators.hpp”
%包括“../../libsnark/libsnark/gadgetlib2/protoboard.hpp”
%包括“../../libsnark/libsnark/gadgetlib2/pp.hpp”
...
我是SWIG新手,不太知道如何编写如此复杂的脚本。C++项目是一个第三方项目,我们不打算去接触它。p>