Reputation: 16942
I am trying to wrap a .h file using SWIG with the following really simple interface file:
%module example
%{
/* Includes the header in the wrapper code */
#include "../pointmatcher/PointMatcher.h"
%}
/* Parse the header file to generate wrappers */
%include "../pointmatcher/PointMatcher.h"
The wrapping attempt fails with the following error:
C:\Data\Projects\lpm-source\libpointmatcher-swig\wrapper>C:\Data\Downloads\swigw
in-3.0.5\swig.exe -csharp -cpperraswarn example.i
..\pointmatcher\PointMatcher.h(61) : Warning 205: CPP #error ""You need libnabo
version 1.0.6 or greater"".
..\pointmatcher\PointMatcher.h(130) : Error: Syntax error in input(1).
The line in question is:
template<typename T>
struct PointMatcher <-- this line
{
from this file: https://github.com/ethz-asl/libpointmatcher/blob/master/pointmatcher/PointMatcher.h#L130
Why is the SWIG parsing failing here?
Upvotes: 0
Views: 157
Reputation: 3043
Swig is parsing the file as a C file instead of C++, and does not understand the template
keyword. Try:
swig -c++ -csharp -cpperraswarn example.i
See the swig documentation on wrapping C++.
Also, the function like macros DEF_REGISTRAR(...)
and DEF_REGISTRAR_IFACE(...)
will confuse swig. So either %include
the file where these are defined, or just define them away by adding
#define DEF_REGISTRAR_IFACE(...)
#define DEF_REGISTRAR(...)
before the %include "../pointmatcher/PointMatcher.h"
.
Upvotes: 1