【发布时间】:2010-05-28 02:44:49
【问题描述】:
我认为这是一个非常标准的列表标题。因为结构
指向它自己,我们需要这个由两部分组成的声明。叫它listicle.h:
typedef struct _listicle listicle;
struct _listicle{
int i;
listicle *next;
};
我正在尝试用 swig 来包装它,以便 Python 用户可以使用 listicle
结构。这是我现在在listicle.i 中的内容:
%module listicle
%{
#include "listicle.h"
%}
%include listicle.h
%rename(listicle) _listicle;
%extend listicle {
listicle() {return malloc (sizeof(listicle));}
}
正如我在这里询问的那样,它不起作用。所有各种组合
我以自己特殊的方式尝试了每一次失败。 [这个:%extend defined for an undeclared class listicle。将其更改为%extend _listicle(并修复构造函数)并在 Python 中加载得到type object '_listicle' has no attribute '_listicle_swigregister'。以此类推。]
建议?
【问题讨论】: