caenyon caenyon - 7 months ago 19
C++ Question

C++, Qt: Variable named "slots" in included external library

I'm using Qt to write a desktop application that includes an external library. The problem is that I get an error when including the external library:

.../sc_containers.h:667: error: expected unqualified-id before ';' token
sc_array_t *slots;

I successfully included the same library in a non-qt project before, so I assume that this error is related to the fact that Qt uses
as a special keyword (see here in the Qt documentation).

Is there a way that I can use that external library in my program? Since this is not my own library, changing the variable name to something else isn't really an option.

Thanks in advance!


Adding QT_NO_KEYWORDS (-DQT_NO_KEYWORDS) definition to your build will prevent Qt from defining foreach, signals, slots which may collide with other frameworks.

Related answer:

Related doc: