我有一个 C++ 库,它提供以下枚举和函数:
typedef enum en{
a,
b
}myEnum;
int myFunction( myEnum &varToSet )
{
varToSet = 1;
return 0;
}
C# Wrapper 中的函数应如下所示:
public static int myFunction( ref myEnum varToSet )
我试图通过遵循 Swig 接口(interface)文件中的类型映射来获得此结果:
%typemap(cstype) myEnum & "ref myEnum"
%typemap(csin) myEnum & %{ref $csinput%}
Swig 在 Wrapper.cs 中将类型从 SWIGTYPE_p_myEnum 更改为 ref myEnum,但在 WrapperPINVOKE.cs 中没有。我在这里缺少什么?
最佳答案
您需要为 imtype 添加类型映射:
%typemap(imtype) myEnum & "ref myEnum"
关于c# - 我如何为 SWIG 定义类型映射,将引用参数从 C++ 转换为 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3360653/