python - gcc 5.2.0 的 boost.python 字符串兼容性
问题描述
接受std::string
输入的函数无法通过带有 gcc/5.2.0 的 boost.python 正确公开;而 gcc 4.8.3 工作正常。
ps 我使用的是预建的 libboost_python.so.1.63。
C++ 代码
#include <boost/python.hpp>
#include <iostream>
using namespace boost::python;
void func(const std::string & hi)
{
std::cout<<hi<<std::endl;
}
BOOST_PYTHON_MODULE(example)
{
def("func", &func);
}
Python 执行
>>> from example import *
>>> func("hi")
Boost.Python.ArgumentError: Python argument types in
example.func(str)
did not match C++ signature:
func(std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >)
解决方案
推荐阅读
- visual-studio - 如何从 Visual Studio 上的项目中删除作为链接添加的文件?
- php - PHP动态导航子菜单
- node.js - MongoNetworkError:连接 ECONNREFUSED 172.18.0.2:27017
- python - 如何在 VS Code 中更改 Python 版本
- angular - 反应式表单是围绕可观察的流构建的
- windows - 我们可以使用 NMAKE.EXE 作为 GNU Make 的替代品吗?
- c# - 使用 COM 互操作从 VSTO C# 列出现有 Access 实例的 MS Access 表
- android - 如何在 opentok Cordova 中的发布者视频顶部显示 HTML 按钮
- javascript - 如何使用复选框禁用使用 Javascript 的表单“月”输入?
- python - 轮询命令 discord.py