【问题标题】:pybind11: what python data structure for a c++ unsigned char*?pybind11:c++ unsigned char* 的 python 数据结构是什么?
【发布时间】:2022-07-23 20:07:26
【问题描述】:

一个 c++ 函数有一个签名:

void f*(unsigned char* buffer, int buffer_size);

可以使用pybind11进行包装:

m.def("f",&f);

我现在纠结于如何在 python 中调用f

例如,使用 ctypes,这样的事情会起作用:

buffer = bytearray(size)
cbuf_type = ctypes.c_char*len(buffer)
cbuf = cbuf_type.from_buffer(buffer)
lib.f(cbuf,size)

pybind11 有什么用?

【问题讨论】:

    标签: python c++ pointers pybind11


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-16
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 2011-04-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多