0
我已阅读http://www.swig.org/Doc1.3/Library.html#Library_nn12并使用以下形式的功能时遇到在Python麻烦:SWIG(C&Python)的cstring.i问题
/* foo.h */
//fills *filename with useful stuff in the usual way
int foo(char *filename);
我有一个接口文件,大约看起来像这样:
%module foo
{% #include "foo.h" %}
%include "foo.h"
%cstring_bounded_output(char *filename, 1024);
extern int foo(char *filename);
swig doc使我相信我可以从python中调用foo()而没有参数,返回值将是python字符串文件名。但是:
In [4]: foo.foo()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-db4ddc3a33ec> in <module>()
----> 1 foo.foo()
TypeError: foo() takes exactly 1 argument (0 given)
foo()仍然期待char *。我的界面文件是否正确?这是从这种类型的C函数获得python值的首选方法吗?
http://web.mit.edu/svn/src/swig-1.3.25/Lib/python/cstring.i很难解析。如果任何人有关于这个宏的功能的信息,这将是很好的一些光。
注意:如果与Swig 1.3.z相关,我会陷入生产环境。此外,我必须在这里使用Swig。
排序正是问题所在。感谢您及时的回复。 – djh