Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在swig生成的C#函数中通过引用传递字符串?_C#_Pass By Reference_Swig - Fatal编程技术网

如何在swig生成的C#函数中通过引用传递字符串?

如何在swig生成的C#函数中通过引用传递字符串?,c#,pass-by-reference,swig,C#,Pass By Reference,Swig,我有以下c函数: int GetB(const char* a, char *b); 我想使用swig生成以下C#函数: int GetB(string a, out string b); 我在swig接口文件中尝试了以下操作: %include "typemaps.i" %apply signed char *OUTPUT {char *b}; int GetB(const char* a, char *OUTPUT); 但这会产生: int GetB(string a, ou

我有以下c函数:

int GetB(const char* a, char *b); 
我想使用swig生成以下C#函数:

int GetB(string a, out string b); 
我在swig接口文件中尝试了以下操作:

%include "typemaps.i" 
%apply signed char *OUTPUT {char *b}; 
int GetB(const char* a, char *OUTPUT); 
但这会产生:

int GetB(string a, out sbyte b) 
如果我使用:

%apply char *OUTPUT {char *b}; 
我得到:

"warning 453: Can't apply (char *OUTPUT). No typemaps are defined."

有没有办法解决这个问题

我猜
string
在C中不是有效的类型,这就是为什么您得到的是
out sbyte b
而不是
out string b
。是的,但也许您可以使用sbyte数组的转换在swig接口文件中以某种方式字符串。