8

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'

How can I get CDK to work with Qt?

plasmacel
  • 8,183
  • 7
  • 53
  • 101
Joe Beuckman
  • 2,264
  • 2
  • 24
  • 63

1 Answers1

18

You can define the QT_NO_KEYWORDS macro, that disables the “signals” and “slots” macros.

If you use QMake:

 CONFIG += no_keywords

(Qt Documentation here)

If you’re using another build system, do whatever it needs to pass -DQT_NO_KEYWORDS to the compiler.

Defining QT_NO_KEYWORDS will require you to change occurrences of signals to Q_SIGNALS and slots to Q_SLOTS in your Qt code.

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>

I'd recommend to use no_keywords though if possible, as it is less tedious and error-prone.

Frank Osterfeld
  • 24,815
  • 5
  • 58
  • 70
  • How does that 2nd suggestion work? `#define QT_NO_KEYWORDS` in a middle of a file will not magically undefine `signals` macro, will it? It'd need to be around Qt includes, not `cdk.h`, wouldn't it? – hyde Mar 05 '14 at 06:49
  • hyde: Oups, indeed. See, it’s error-prone ;) Removed the hint. – Frank Osterfeld Mar 05 '14 at 06:56