学无先后,达者为师

网站首页 编程语言 正文

C++在Qt中使用Python报错

作者:weixin_101 更新时间: 2023-07-08 编程语言

一. 导入头文件报错

In included file: expected member name or ‘;’ after declaration specifiers object.h:227:23: error occurred here
在这里插入图片描述



原因:

This happens because including Python.h first indirectly includes termios.h, which defines B0 to be 0, which in turn qpagedpaintdevice.h want’s to use as a variable name. Including Python.h after the Qt includes does pretty much the same thing the other way around with the string ‘slots’.



解决

  1. 双击错误打开文件 object.h 文件
    在这里插入图片描述

  2. 把冲突的slots 使用undef 和define

 PyType_Slot *slots; /* terminated by slot==0. */
 更改为
 #undef slots
 PyType_Slot *slots; /* terminated by slot==0. */
 #define slots Q_SLOTS

在这里插入图片描述

重新构建项目 已解决问题
在这里插入图片描述



原文链接:https://blog.csdn.net/weixin_41560737/article/details/127269010

  • 上一篇:没有了
  • 下一篇:没有了
栏目分类
最近更新