设为首页 加入收藏

TOP

Pybind11绑定C++抽象类(DLL接口)(二)
2023-09-09 10:25:48 】 浏览:289
Tags:Pybind11 绑定 DLL 接口
;类型进行转换。

绑定Pybind

// 绑定代码
PYBIND11_MODULE(my_module, m) {
    py::class_<Wrapper, std::shared_ptr<Wrapper>>(m, "Wrapper")
        .def(py::init<AbstractDLLInterface*>())
        .def("dllFunction", &Wrapper::dllFunction);
}

注意此时我们不需要绑定AbstractDLLInterface类,绑定AbstractDLLInterface类编译时会报错。py::class_传入参数Wrapper, std::shared_ptr<Wrapper>可以保证Python可以识别Wrapper和Wrapper的指针。

本文为李你干嘛原创,转载请注明出处:Pybind11绑定C++抽象类(DLL接口)

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Lyndon分解 学习笔记 下一篇C++ ASIO 实现异步套接字管理

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目