⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

error expected constructor, destructor, or type conversion before ‘ when trying to register a structure from my C library

  • Hello, i'm trying to register a structure in my C library, in order to use it with signals and slots.

    #ifndef MQTTMANAGER_H
    #define MQTTMANAGER_H
    #include <QObject>
    #include <QMetaType>
    #include "core/interface/MQTTClient.h"
    class MqttManager: public QObject
        MqttManager(QObject *parent = 0);
        void setupParameters();
        titanium_DbErrorCode doMqttClientCreate();
        titanium_DbErrorCode doConnect();
        titanium_DbErrorCode doPublish(QString& p_topic,const QString& p_payload, int p_qos=0,int p_retain=false);
        titanium_DbErrorCode doSubscribe(QString p_topic,int p_qos=0);
        void doUnsubscribe(QString& p_topic);
        void doDisconnect();
        void doMqttClientDestroy();
        static void message_Cb(void* p_ReceiverStruct, void* p_Data);
        void signalEmit(QString);
        static  MqttManager* m_manager;
    public slots:
        void messageReceived(QString);
        QString m_hostname;
        int m_port;
        titanium_MQTTClient *m_client;
        titanium_MQTTConnectionSettings m_connectionSettingsMQTT;
        titanium_MQTTOnMessageCallback m_messageCallBack;
        bool m_autoReconnect;

    In my main function i use QRegisterMetatype because i have communication between threads:

    I get the error:
     expected constructor, destructor, or type conversion before ‘;’ token

  • @Babs what is this titanium_MQTTMessage?
    Is it structure type or instance of structure?


    It must be declared with Q_DECLARE_METATYPE()

  • @nagesh it is a struct type

  • @nagesh i did the declaration with Q_DECLARE_METATYPE

  • @nagesh thank you it solved i did the QRegisterMetaType just before connecting the signal to slot

Log in to reply