Qt macro keywords cause name collisions(Qt 宏关键字导致名称冲突)
问题描述
我正在为我的 Qt 项目构建一个 NCurses 界面.我想使用 CDK,但我认为该结构的 signals 成员与 Qt signals 关键字发生冲突.
I am building an NCurses interface for my Qt project. I want to use CDK but I think the signals member of this struct is colliding with the Qt signals keyword.
/usr/include/linux/cdk.h:411: error: expected unqualified-id before 'protected'
如何让 CDK 与 Qt 一起工作?
How can I get CDK to work with Qt?
推荐答案
您可以定义 QT_NO_KEYWORDS 宏,禁用信号"和槽"宏.
You can define the QT_NO_KEYWORDS macro, that disables the "signals" and "slots" macros.
如果您使用 QMake:
If you use QMake:
 CONFIG += no_keywords
(Qt 文档在这里)
如果您使用其他构建系统,请执行任何需要将 -DQT_NO_KEYWORDS 传递给编译器的操作.
If you’re using another build system, do whatever it needs to pass -DQT_NO_KEYWORDS to the compiler.
定义 QT_NO_KEYWORDS 将要求您将 Qt 中 signals 的出现次数更改为 Q_SIGNALS 并将 slots 的出现次数更改为 Q_SLOTS代码.
Defining QT_NO_KEYWORDS will require you to change occurrences of signals to Q_SIGNALS and slots to Q_SLOTS in your Qt code.
如果您无法更改所有 Qt 代码,例如因为您使用的第三方库不是关键字清理",您可以尝试在包含 cdk.h 之前在本地取消定义信号":
If you cannot change all the Qt code, e.g. because you're using third-party libraries not being "keyword-clean", you could try to undefine "signals" locally before including cdk.h:
#undef signals
#include <cdk.h>
如果可能的话,我建议使用 no_keywords,因为它不那么乏味且不易出错.
I'd recommend to use no_keywords though if possible, as it is less tedious and error-prone.
这篇关于Qt 宏关键字导致名称冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Qt 宏关键字导致名称冲突
				
        
 
            
        基础教程推荐
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
 - 如何通过C程序打开命令提示符Cmd 2022-12-09
 - 在 C++ 中计算滚动/移动平均值 2021-01-01
 - 常量变量在标题中不起作用 2021-01-01
 - 如何检查GTK+3.0中的小部件类型? 2022-11-30
 - 如何在 C++ 中初始化静态常量成员? 2022-01-01
 - 我有静态或动态 boost 库吗? 2021-01-01
 - 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
 - 这个宏可以转换成函数吗? 2022-01-01
 - C++结构和函数声明。为什么它不能编译? 2022-11-07
 
    	
    	
    	
    	
    	
    	
    	
    	
						
						
						
						
						
				
				
				
				