C# Swig csclassmodifiers不适用于C函数的模块类

C# Swig csclassmodifiers不适用于C函数的模块类,c#,c++,swig,C#,C++,Swig,我正在尝试生成一个C#SWIG包装器,一个流行的开源技术指标库 TA Lib代码是C代码(外部“C”函数的集合),因此,Swig生成如下类: // where ModuleName is specified as %module "ModuleName" // where SomeCFunc is an extern "C" function in the target C dll public class ModuleName { public void SomeCFunc(...)

我正在尝试生成一个C#SWIG包装器,一个流行的开源技术指标库

TA Lib代码是C代码(外部“C”函数的集合),因此,Swig生成如下类:

// where ModuleName is specified as %module "ModuleName"
// where SomeCFunc is an extern "C" function in the target C dll
public class ModuleName { 
    public void SomeCFunc(...)
}
不过。我需要将我的类ModuleName定义为public。过去我用过例如

这应该生成类为“代码>公共不安全的部分< /代码>,但在这种情况下,它不工作,因为类是从模块名生成的,我本身没有包装C++类。p>


有什么想法吗

我一发布,就发现了如何做到这一点(尽管花了一天的时间!)

因此,解决方案是在*.i Swig接口文件中指定moduleclassmodifiers

%pragma(csharp) moduleclassmodifiers="public unsafe partial class"
输出模块类现在生成为

// where ModuleName is specified as %module "ModuleName"
// where SomeCFunc is an extern "C" function in the target C dll
public unsafe partial class ModuleName { 
    public void SomeCFunc(...)
}

我一发帖,就发现了如何做到这一点(尽管花了一天的时间!)

因此,解决方案是在*.i Swig接口文件中指定moduleclassmodifiers

%pragma(csharp) moduleclassmodifiers="public unsafe partial class"
输出模块类现在生成为

// where ModuleName is specified as %module "ModuleName"
// where SomeCFunc is an extern "C" function in the target C dll
public unsafe partial class ModuleName { 
    public void SomeCFunc(...)
}