Here's what I take to be a pretty standard header for a list. Because the struct
points to itself, we need this two-part declaration. Call it listicle.h
:
typedef struct _listicle listicle;
struct _listicle{
int i;
listicle *next;
};
I'm trying to get swig to wrap this, so that the Python user can make use of the listicle
struct. Here's what I have in listicle.i
right now:
%module listicle
%{
#include "listicle.h"
%}
%include listicle.h
%rename(listicle) _listicle;
%extend listicle {
listicle() {return malloc (sizeof(listicle));}
}
As you can tell by my being here asking, it doesn't work. All the various combinations
I've tried each fail in their own special way. [This one: %extend defined for an undeclared class listicle
. Change it to %extend _listicle
(and fix the constructor) and loading in Python gives type object '_listicle' has no attribute '_listicle_swigregister'
. And so on.]
Suggestions?