Reputation: 58
I am getting a "Syntax error in input" error using SWIG on the following line of code
template<typename T>
void print_vec(std::vector<T> vec, int length = -1);
in my .i file, I include the following line
%template(print_vec_int) print_vec<int>;
What am I doing wrong?
Upvotes: 0
Views: 143
Reputation: 168626
You are swigging C++ code, but telling swig it is C. You need to add -c++
to the swig command line.
swig -o x_wrap.cc -c++ -python x.i
If you are using SCons, then you need to update the SWIGFLAGS environment variable:
env = Environment(SWIGFLAGS=['-c++', '-python'])
Upvotes: 1