带C+的简单SWIG+;对于python编译,但输出似乎不正确?

带C+的简单SWIG+;对于python编译,但输出似乎不正确?,python,c++,visual-studio,spyder,swig,Python,C++,Visual Studio,Spyder,Swig,我对SWIG(和c++)相当陌生,所以我尝试使用一个示例 这似乎是一个简单的代码。我在VisualStudio上成功地编译了它 1>------ Rebuild All started: Project: minimal, Configuration: Release x64 ------ 1>Performing Custom Build Tools 1>minimal.cpp 1>minimal_wrap.cxx 1> Creating library ..

我对SWIG(和c++)相当陌生,所以我尝试使用一个示例 这似乎是一个简单的代码。我在VisualStudio上成功地编译了它

1>------ Rebuild All started: Project: minimal, Configuration: Release x64 ------
1>Performing Custom Build Tools
1>minimal.cpp
1>minimal_wrap.cxx
1>   Creating library ..._minimal2.lib and object ...minimal2.exp
1>Generating code
1>Previous IPDB not found, fall back to full compilation.
1>All 70 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
1>Finished generating code
1>minimal.vcxproj -> C:\...\_minimal.pyd
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
但当我试图在spyder(ipython控制台)上运行它时


输出
,所以看起来我必须添加“typemaps.I”并定义输出类型。我没有研究上面问题中使用的示例,但我发现非常有用

/* typemaps.i allows input and output pointer arguments to be specified using the names INPUT, OUTPUT, or INOUT */
%include "typemaps.i"

void   hw1(double r1, double r2, double *OUTPUT);

这个例子显示他们的第一次尝试失败了,我得到了类似指针的响应。然后在typeamps.i之后,它的hw1函数就可以工作了

看来我必须添加“typemaps.I”并定义输出类型。我没有研究上面问题中使用的示例,但我发现非常有用

/* typemaps.i allows input and output pointer arguments to be specified using the names INPUT, OUTPUT, or INOUT */
%include "typemaps.i"

void   hw1(double r1, double r2, double *OUTPUT);

这个例子显示他们的第一次尝试失败了,我得到了类似指针的响应。然后在typeamps.i之后,它的hw1函数就可以工作了

因此,如果你阅读swig文档,通常不需要打印地图。。。我认为在这种情况下(hw1),它是必要的,因为空洞函数的构造方式。我刚刚测试了另一个带有int函数的简单c文件,它在没有类型映射的情况下运行良好(只需输入extern int或extern double)。。。我认为在这种情况下(hw1),它是必要的,因为空洞函数的构造方式。我刚刚测试了另一个带有int函数的简单c文件,它在没有类型映射的情况下运行良好(只需放入extern int或extern double)。
/* typemaps.i allows input and output pointer arguments to be specified using the names INPUT, OUTPUT, or INOUT */
%include "typemaps.i"

void   hw1(double r1, double r2, double *OUTPUT);