推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
Lighthughjiajin
V2EX  ›  Python

Python2 调用 so 文件时,如何传递 C++ std::string& json 和 int* 类型 的参数

  •  
  •   Lighthughjiajin · Dec 20, 2022 · 3881 views
    This topic created in 1241 days ago, the information mentioned may be changed or developed.

    Python 调用 C++ 编译好的 .so 文件,如何传递 C++ 里声明的 std::string& json 和 int* 类型的参数。

    8 replies    2022-12-22 17:18:49 +08:00
    leonshaw
        1
    leonshaw  
       Dec 20, 2022 via Android
    接口用 C 封装
    Lighthughjiajin
        2
    Lighthughjiajin  
    OP
       Dec 20, 2022
    SO 文件是别人提供的,不是我自己写的 。
    ysc3839
        3
    ysc3839  
       Dec 20, 2022 via Android
    @Lighthughjiajin 你还可以写一个 so 再封装一些
    ysc3839
        4
    ysc3839  
       Dec 20, 2022 via Android
    @ysc3839 再封装一下
    junmoxiao
        5
    junmoxiao  
       Dec 20, 2022
    别说用 py 调 c++写的动态库了,你用不同编译器版本的 c++调 c++写的动态库都可能出问题。因为在不同的版本,标准库组件的实现、内存布局可能发生了改变。
    接口最好还是用 c
    elechi
        6
    elechi  
       Dec 21, 2022
    C++ 相互之间调用都不推荐用 std 库的类型,因为不同版本的 std 实现都是有差异的。。。
    NoAnyLove
        7
    NoAnyLove  
       Dec 22, 2022
    没有 extern "C"吗?要不试试 cython 或者 cppyy ?
    newmlp
        8
    newmlp  
       Dec 22, 2022
    建议直接 char*,传对象是不可能的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3731 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 10:37 · PVG 18:37 · LAX 03:37 · JFK 06:37
    ♥ Do have faith in what you're doing.