alecthomas / entityx

EntityX - A fast, type-safe C++ Entity-Component system
MIT License
2.23k stars 295 forks source link

Can't use entityx in Qt : conflicts with simplesignal #230

Closed mean-ui-thread closed 5 years ago

mean-ui-thread commented 5 years ago

to reproduce this issue, you only need to include the entityx.h. Example:

#include <QObject>
#include <entityx/entityx.h> // <----- That's all that is needed to reproduce this issue

class MyObject : public QObject {
    Q_OBJECT

public:
    explicit MyObject(QObject *parent = nullptr);
};

will generate a few compiler issues such as:

/home/mchiasson/.hunter/_Base/f7dece3/db81cfd/4251933/Install/include/SimpleSignal/SimpleSignal.h:114:13: error: expected ‘)’ before ‘...’ token
   emit (Args... args) const
             ^~~
/home/mchiasson/.hunter/_Base/f7dece3/db81cfd/4251933/Install/include/entityx/Event.h:155:13: error: expected unqualified-id before ‘const’
   void emit(const E &event) {
             ^~~~~
/home/mchiasson/.hunter/_Base/f7dece3/db81cfd/4251933/Install/include/entityx/Event.h:155:13: error: expected ‘)’ before ‘const’
/home/mchiasson/.hunter/_Base/f7dece3/db81cfd/4251933/Install/include/entityx/Event.h:164:32: error: invalid declarator before ‘event’
   void emit(std::unique_ptr<E> event) {
                                ^~~~~

etc.

problem is, both Qt and SimpleSignal provide an emit token at the global scope.

mean-ui-thread commented 5 years ago

I discovered that the version of entityx in the compile_time branch works fine with Qt, and even has an example with Qt and QML. Thank you!

alecthomas commented 5 years ago

Excellent!