小编sap*_*api的帖子

在 SWIG 中使用 unsigned char 数组的共享指针

我正在使用 SWIG 使 C++ 代码在 C# 中可用。其中一项任务是通过std::shared_ptr<unsigned char> 表示无符号字符数组来交换数据。尺寸单独给出。我认为 C# 中合适的表示形式是byte[].

不幸的是我无法管理这个“翻译”。以下是 SWIG 接口文件示例:

%module example
%include <stdint.i>
%include <std_pair.i>
%include <std_shared_ptr.i>
%include <arrays_csharp.i>

// would result in compile error: "error C2679: binary '=' : no operator found which takes a right-hand operand of type 'unsigned char *' (or there is no acceptable conversion)"
//%apply unsigned char INPUT[]  {std::shared_ptr<unsigned char>}
//%apply unsigned char OUTPUT[] {std::shared_ptr<unsigned char>}

%apply unsigned char INPUT[]  {unsigned char*}
%apply unsigned char OUTPUT[] {unsigned …
Run Code Online (Sandbox Code Playgroud)

c# c++ swig shared-ptr

5
推荐指数
0
解决办法
557
查看次数

标签 统计

c# ×1

c++ ×1

shared-ptr ×1

swig ×1