Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt name collision, but no_keywords not an option

I have a dilemma. In a program I'm writing using Qt, I use a (non-Qt) library that uses a Qt keyword in its headers as a name (the library being pf_ring to be precise, and the name "slots") and so I get compilation errors. But if I turn off Qt keywords using the no_keywords option, the compiler complains about another library's headers (this one Qt-based) which use Qt keywords like "signals" and "slots."

So how can I fix this? I can think of only two options neither of which is very satisfactory:

  1. I can change the second library's header files so that they comply with the no_keywords mode (changing "slots" to "Q_SLOTS" and so forth).

  2. I can move the pf_ring related code into its own sub-project in which I can turn off Qt keywords or simply not use Qt at all.

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

like image 253
Elektito Avatar asked May 19 '13 18:05

Elektito


1 Answers

This depends on the library, if it's a small one you can make a "wrapper" header (only or not) that doesn't expose slots or expose it in a wrapper_namespace (note that you can use #undef slots ).

like image 177
Zlatomir Avatar answered Oct 31 '22 23:10

Zlatomir