python - 尝试使用 boost.python 从 python 将参数传递给 c++ 函数
问题描述
我正在尝试从 python 运行我的 c++ 应用程序。我已经设置了 boost.python 来允许我这样做;但是,我试图调用的 c++ 函数需要我在构建之前输入到 Visual Studio 的控制台参数。现在我有这个来自 python 的可调用对象,我很想通过 python 端传递这些参数。
我试图通过将参数输入 python 函数来输入它,但它存在转换问题。
这是错误消息:
Boost.Python.ArgumentError: Python argument types in
cplusplus.function(int, str, str, str, str)
did not match C++ signature:
function(int, char * __ptr64 * __ptr64)
如果有一种方法可以将字符串转换为 char* __ptr64 那就太好了。或者,如果有一种自动方式,那就更好了。
使用 python 3.7 visual studio 16.3 和最新的 boost(1.71)。我很乐意提供的任何其他信息
这是我的带参数的 c++ 函数声明:int notmain(int argc, char* argv[]) {
而python方面调用它:(
print (cplusplus.function(Port, Server, user, pass, request))
端口是一个int,其余的是字符串。)
对此的任何建议/见解将不胜感激,谢谢!
布雷迪
解决方案
推荐阅读
- javascript - 带有 .appendchild() 的 Javascript for 循环正在从 html dom 中的 [object object] 附加最后一个对象的值
- matlab - 从 SImulink 中的 FFT 模块输出数组中提取一次谐波分量
- php - PHP如何根据参数数量获取下个月的继续日期?
- php - 从输出 CodeIgniter 中删除多余的空格
- java - 无法在 Firebase 存储中检索图像 url
- flash - 构建使用 Flash SDK 2 构建的遗留项目
- qt - 如何在 QML 中删除图表视图与其 Plotarea 之间的间距
- angular - CSS样式不生效
- node.js - 当 xml 模式验证失败时,Nodejs libxmljs 使 docker 容器崩溃
- ruby - 为什么我不能将类错误与链一起进一步发送?