在qt5中使用XShapeCombineRectangles编译报错

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

引用了两个头文件:

#include 
#include 

编译的时候会报错:
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中的答案,去掉用宏定义的类型即可成功编译:

#include 
#include 

#undef Bool
#undef CursorShape
#undef Expose
#undef KeyPress
#undef KeyRelease
#undef FocusIn
#undef FocusOut
#undef FontChange
#undef None
#undef Status
#undef Unsorted

你可能感兴趣的:(qt,开发语言,linux)