Qt name collision, but no_keywords is not an option

I have a dilemma. In the program that I write with Qt, I use a library (not Qt) that uses the Qt keyword in its headers as the name (the library being exact pf_ring and the name is “slots”), and therefore I get a collection of errors. But if I disable Qt keywords using the no_keywords option, the compiler complains about other library headers (based on Qt) that use Qt keywords, such as “signals” and “slots”.

So how can I fix this? I can only think of two options, none of which are satisfactory:

  • I can change the header files of the second library to match the no_keywords mode (changing the “slots” to “Q_SLOTS”, etc.).

  • I can move the pf_ring-related code into my own subproject in which I can turn off the Qt keywords or just not use Qt at all.

Can you suggest another, hopefully more elegant and less troublesome solution?

+4
source share
1 answer

It depends on the library, if it is small, you can create a wrapper header (only or not) that does not expose slots or expose it in wrapper_namespace (note that you can use #undef slots).

+5
source

Source: https://habr.com/ru/post/1481650/


All Articles