error on webrtc base/sigslot.h file: error: expected ')' before '...' token void emit(Args... args) const
-
Hi everone!
I'm trying to use google webrtc api, but I got some errors on sigslot.h file while compiling project. Error on this class:class _opaque_connection { private: typedef void (*emit_t)(const _opaque_connection*); template< typename FromT, typename ToT > union union_caster { FromT from; ToT to; }; emit_t pemit; has_slots_interface* pdest; // Pointers to member functions may be up to 16 bytes for virtual classes, // so make sure we have enough space to store it. unsigned char pmethod[16]; public: template< typename DestT, typename ... Args > _opaque_connection(DestT* pd, void (DestT::*pm)(Args...)) : pdest(pd) { typedef void (DestT::*pm_t)(Args...); static_assert(sizeof(pm_t) <= sizeof(pmethod), "Size of slot function pointer too large."); std::memcpy(pmethod, &pm, sizeof(pm_t)); typedef void (*em_t)(const _opaque_connection* self, Args...); union_caster< em_t, emit_t > caster2; caster2.from = &_opaque_connection::emitter< DestT, Args... >; pemit = caster2.to; } has_slots_interface* getdest() const { return pdest; } _opaque_connection duplicate(has_slots_interface* newtarget) const { _opaque_connection res = *this; res.pdest = newtarget; return res; } // Just calls the stored "emitter" function pointer stored at construction // time. template< typename ... Args > void emit(Args... args) const { typedef void (*em_t)(const _opaque_connection*, Args...); union_caster< emit_t, em_t > caster; caster.from = pemit; (caster.to)(this, args...); } private: template< typename DestT, typename ... Args > static void emitter(const _opaque_connection* self, Args... args) { typedef void (DestT::*pm_t)(Args...); pm_t pm; std::memcpy(&pm, self->pmethod, sizeof(pm_t)); (static_cast< DestT* >(self->pdest)->*(pm))(args...); } };error:
expected ')' before '...' token void emit(Args... args) const ^what is wrong?
HELP -
Don't know what this has to do with Qt but I suppose it might be a naming clash, see http://doc.qt.io/qt-5/signalsandslots.html#using-qt-with-3rd-party-signals-and-slots
-
Hi everone!
I'm trying to use google webrtc api, but I got some errors on sigslot.h file while compiling project. Error on this class:class _opaque_connection { private: typedef void (*emit_t)(const _opaque_connection*); template< typename FromT, typename ToT > union union_caster { FromT from; ToT to; }; emit_t pemit; has_slots_interface* pdest; // Pointers to member functions may be up to 16 bytes for virtual classes, // so make sure we have enough space to store it. unsigned char pmethod[16]; public: template< typename DestT, typename ... Args > _opaque_connection(DestT* pd, void (DestT::*pm)(Args...)) : pdest(pd) { typedef void (DestT::*pm_t)(Args...); static_assert(sizeof(pm_t) <= sizeof(pmethod), "Size of slot function pointer too large."); std::memcpy(pmethod, &pm, sizeof(pm_t)); typedef void (*em_t)(const _opaque_connection* self, Args...); union_caster< em_t, emit_t > caster2; caster2.from = &_opaque_connection::emitter< DestT, Args... >; pemit = caster2.to; } has_slots_interface* getdest() const { return pdest; } _opaque_connection duplicate(has_slots_interface* newtarget) const { _opaque_connection res = *this; res.pdest = newtarget; return res; } // Just calls the stored "emitter" function pointer stored at construction // time. template< typename ... Args > void emit(Args... args) const { typedef void (*em_t)(const _opaque_connection*, Args...); union_caster< emit_t, em_t > caster; caster.from = pemit; (caster.to)(this, args...); } private: template< typename DestT, typename ... Args > static void emitter(const _opaque_connection* self, Args... args) { typedef void (DestT::*pm_t)(Args...); pm_t pm; std::memcpy(&pm, self->pmethod, sizeof(pm_t)); (static_cast< DestT* >(self->pdest)->*(pm))(args...); } };error:
expected ')' before '...' token void emit(Args... args) const ^what is wrong?
HELP@Nabi
You have line:void emit(Args... args) constin your code. I'm not a C++ expert, but is that really legal?
Alternatively, if you are posting here because you have also included Qt header files into your source file, be aware that Qt defines, I believe, an
emitas a macro (which expands to nothing, I think), and that just might be interfering with theemit()you have here? -
@JonB Yes it is. See parameter pack.
-
@JonB Yes it is. See parameter pack.
@SGaist
C++ is getting (even more) ridiculous then!So given OP's compiler error message, what's wrong then?! Wrong compiler C++ version?
emitdefined as a macro by Qt if OP has included a Qt header file, since he's posting on a Qt forum? C++ just feeling grumpy/having a bad-hair day? -
@SGaist
C++ is getting (even more) ridiculous then!So given OP's compiler error message, what's wrong then?! Wrong compiler C++ version?
emitdefined as a macro by Qt if OP has included a Qt header file, since he's posting on a Qt forum? C++ just feeling grumpy/having a bad-hair day?