【发布时间】:2015-07-14 16:44:51
【问题描述】:
错误信息:
Error: Syntax error in input(1)
我的 Swig 文件:
%module interfaces
%{
#include <vector>
#include <list>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/linestring.hpp>
typedef boost::geometry::model::d2::point_xy<double> Point;
typedef boost::geometry::model::polygon<Point, true, false> Polygon;
%}
%include "std_vector.i"
%template(MultiPolygon) std::vector<Polygon>;
%template(pgon) Polygon;
如果我注释掉最后一行,它会编译
// %template(pgon) Polygon;
我一直在重新阅读有关模板的 swig 部分,但我完全不明白出了什么问题。我做错了什么,我该如何解决?
【问题讨论】:
-
错误信息是什么...?
-
Polygon不再是模板,而是具体类型,那么为什么需要%template(pgon)?如果您希望在 Python 世界中将Polygon称为pgon,则 SWIG 可能有一些其他语法来创建别名。 -
@Praetorian Polygon 还不是模板类吗?在阅读 Swig 的文档时,我的印象是任何定义中带有 的类都需要包装在 %template() 中
-
@KarolyHorvath 错误:输入中的语法错误 (1)。
-
polygon是一个类模板,polygon<Point, true, false>或者它的别名,不再是一个模板,你已经通过提供所有模板参数来专门化它,它现在是一个真正的类型.
标签: python c++ boost swig boost-geometry