简体   繁体   English

从C#调用从C(swig接口)导出的函数

[英]Calling a function exported from C (swig interface) from C#

I have a function in C language with definition like 我有一个C语言的功能,定义如

uint8 *callme (uint8 a, uint8 b, uint8 c)

In interface.i file I have defined function as 在interface.i文件中我将函数定义为

%module abc
%{
.... C Header files (.h)
%}
extern void uint8 *callme (uint8 a, uint8 b, uint8 c);

I have generated .a file with XCode Cocoa touch library and .dll file from generated .cs files. 我用生成的.cs文件生成了带有XCode Cocoa touch库和.dll文件的.a文件。

I am trying to call this callme function from my C# code in Xamarin iOS app. 我试图从Xamarin iOS应用程序中的C#代码调用此callme函数。 But I am not sure how to pass the value to this function. 但我不知道如何将值传递给此函数。 Every time I am getting error as "Cannot convert from datatype to abc.SWIGTYPE_p_uint8" 每次我收到错误“无法从数据类型转换为abc.SWIGTYPE_p_uint8”

Every type for which SWIG creates a *SWIGTYPE_p_** is a type that is not understood by SWIG. SWIG创建* SWIGTYPE_p _ **的每种类型都是SWIG无法理解的类型。

You need to look arround Typemaps . 你需要查看arround Typemaps

You have some example of C# typemaps in the typemaps.i you can find in [swig_file]/lib/csharp. 您可以在[swig_file] / lib / csharp中找到typemaps.i中的C#类型映射示例。

When you will have the correct typemaps for an uint8, your problem should be fixed. 如果你有一个uint8的正确的类型图,你的问题应该修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM