我正在尝试将c ++项目libsnark包装到golang中。 我收到以下警告,
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 ++代码段
class Variable {
/**
* @brief allocates the variable
*/
public:
explicit Variable(const ::std::string& name = "");
virtual ~Variable();
...
}; // class Variable
typedef ::std::vector<Variable> VariableArrayContents;
class VariableArray : public VariableArrayContents {
public:
using VariableArrayContents::operator[];
using VariableArrayContents::at;
using VariableArrayContents::push_back;
using VariableArrayContents::size;
...
}
这是我的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"
...
我是SWIG的新手,不太了解如何编写这种复杂的脚本。 c ++项目是第三方项目,我们不打算涉及它。