在qt5中使用XShapeCombineRectangles编译报错

linux x11环境中,在qt5中使用XShapeCombineRectangles去实现鼠标穿透

引用了两个头文件:

c++ 复制代码
#include <QX11Info>
#include <X11/extensions/shape.h>

编译的时候会报错:

Desktop_Qt_5_12_12_GCC_64bit-Debug/moc_mainwindow.cpp:86: error: expected unqualified-id before 'int'

In file included from /usr/include/X11/Xutil.h:53,

from /usr/include/X11/extensions/shape.h:34,

from .../tablet/mainwindow.h:58,

from moc_mainwindow.cpp:9:

moc_mainwindow.cpp:86:33: error: expected unqualified-id before 'int'

86 | QMetaType::Void, QMetaType::Bool, 9,

| ^~~~

根据报错信息,可查到是x11/xlib.h这个库中使用define定义了一些类型导致qt编译报错

https://stackoverflow.com/questions/22476110/c-compiling-error-including-x11-x-h-x11-xlib-h/41837372#41837372

根据stackoverflow中的答案,去掉用宏定义的类型即可成功编译:

c++ 复制代码
#include <QX11Info>
#include <X11/extensions/shape.h>

#undef Bool
#undef CursorShape
#undef Expose
#undef KeyPress
#undef KeyRelease
#undef FocusIn
#undef FocusOut
#undef FontChange
#undef None
#undef Status
#undef Unsorted
相关推荐
爱网络爱Linux5 小时前
【系列】每天一个 Linux 命令(53)startx 命令
linux·rhce·rhca·linux运维·linux命令大全·红帽认证
ZhengEnCi6 小时前
L2A-一个域名如何访问多台云服务器-子域名、路径前缀与Nginx反向代理选型指南
linux·人工智能
M78佐菲6 小时前
51单片机学习笔记:ds18b20要点整理
linux·笔记·嵌入式硬件·学习·51单片机
lsswear6 小时前
Python 并发 线程
开发语言·python
郑州光合科技余经理6 小时前
国际版外卖系统:税率字段怎么和订单主流程解耦
android·java·开发语言·前端·后端·php·ai编程
高亦真6 小时前
今天是学习嵌入式的第37天
linux·学习·算法
软件课代表CiCi6 小时前
运行库是什么?电脑缺运行库怎么办?c++运行库缺失修复全攻略
开发语言·c++·windows·电脑·dll修复·dll丢失·运行库
Ivanqhz7 小时前
MLIR OpBuilder
开发语言·python·mlir
一个有温度的技术博主7 小时前
Linux 核心命令速查指南:从文件操作到系统运维
linux·服务器
小小的木头人7 小时前
Docker 环境下迁移 containerd 数据目录:从 `/var/lib/containerd` 到 `/data/containerd`
linux·docker