Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. error: expected constructor, destructor, or type conversion before ‘enum’ while building in linux with make
Forum Updated to NodeBB v4.3 + New Features

error: expected constructor, destructor, or type conversion before ‘enum’ while building in linux with make

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ravi2k18
    wrote on last edited by
    #1

    Hi,

    I am facing below build error while building the qt project.

    /home/ravi/> make
    g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -std=c++11  -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -o discoverythread.o onvif/discoverythread.cpp
    In file included from onvif/discoverythread.cpp:2:0:
    ./onvif/discoveryobj.h:10:1: error: expected constructor, destructor, or type conversion before ‘enum’
     enum DiscoveryMode{
     ^
    ./onvif/discoveryobj.h:31:5: error: ‘DiscoveryMode’ does not name a type
         DiscoveryMode mode;
         ^
    ./onvif/discoveryobj.h:39:32: error: expected ‘)’ before ‘mode’
         DiscoveryObj(DiscoveryMode mode, int _metadataVersion, char* _xaddr, char* _type, char* _scope, char* _endpoint);
    ravi@134.141.242.126:/home/ravi/cprog/OnvifDiscoveryLib/>make
    g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -std=c++11  -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -o discoverythread.o onvif/discoverythread.cpp
    In file included from onvif/discoverythread.cpp:2:0:
    ./onvif/discoveryobj.h:10:1: error: expected constructor, destructor, or type conversion before ‘enum’
     enum DiscoveryMode{
     ^
    ./onvif/discoveryobj.h:31:5: error: ‘DiscoveryMode’ does not name a type
         DiscoveryMode mode;
         ^
    ./onvif/discoveryobj.h:39:32: error: expected ‘)’ before ‘mode’
         DiscoveryObj(DiscoveryMode mode, int _metadataVersion, char* _xaddr, char* _type, char* _scope, char* _endpoint);
                                    ^
    Makefile:299: recipe for target 'discoverythread.o' failed
    make: *** [discoverythread.o] Error 1
    
    // File name: discoveryobj.h
    
    #ifndef prob_H
    #define prob_H
    
    #include <QVector>
    #include <QString>
    #include <QObject>
    #include "descdevice.h"
    #include "discoverythread.h"
    
    enum DiscoveryMode{
        SERVER_MODE, CLIENT_MODE
    };
    
    class DiscoveryObj: public QObject{
    
        Q_OBJECT   
    signals:
        void discoveredDevice(DescDevice);
    
    private:
        DiscoveryThread discoveryThread;
    
    public:
    //    const int   _metadataVersion = 1;
    //    const char* _xaddr="http://localhost/service";
    //    const char* _type="\"http://schemas.xmlsoap.org/ws/2006/02/devprof\":device";
    //    const char* _scope="scope";
    //    const char* _endpoint="urn";
    
    
        DiscoveryMode mode;
        static DiscoveryObj *theDiscovery;
        int   _metadataVersion;
        char* _xaddr;
        char* _type;
        char* _scope;
        char* _endpoint;
    
        DiscoveryObj(DiscoveryMode mode, int _metadataVersion, char* _xaddr, char* _type, char* _scope, char* _endpoint);
        ~DiscoveryObj();
    
        int sendProb();
        int sendHello();
        int sendBye();
    };
    
    #endif
    
    
    // Filename: discoverythread.h
    
    #ifndef MYTHREAD_H
    #define MYTHREAD_H
    #include <QThread>
    
    class DiscoveryThread : public QThread
    {
        const char* host = "239.255.255.250";
        int port = 3702;
    //    const int   _metadataVersion = 1;
    //    const char* _xaddr="http://localhost/service";
    //    const char* _type="\"http://schemas.xmlsoap.org/ws/2006/02/devprof\":device";
    //    const char* _scope="scope";
    //    const char* _endpoint="urn";
        Q_OBJECT
    public:
        DiscoveryThread();
    protected:
        void run();
    };
    
    #endif // MYTHREAD_H
    
    
    // File Name: descdevice.h
    
    #ifndef DESCDEVICE
    #define DESCDEVICE
    
    struct DescDevice{
        int metadataversion;
        QString types;
        QString xAddrs;
        QString scopes;
    };
    
    Q_DECLARE_METATYPE(DescDevice)
    
    #endif // DESCDEVICE
    

    can any one help me in understating what is wrong here?

    thanks

    jsulmJ J.HilkJ 3 Replies Last reply
    0
    • R ravi2k18

      Hi,

      I am facing below build error while building the qt project.

      /home/ravi/> make
      g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -std=c++11  -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -o discoverythread.o onvif/discoverythread.cpp
      In file included from onvif/discoverythread.cpp:2:0:
      ./onvif/discoveryobj.h:10:1: error: expected constructor, destructor, or type conversion before ‘enum’
       enum DiscoveryMode{
       ^
      ./onvif/discoveryobj.h:31:5: error: ‘DiscoveryMode’ does not name a type
           DiscoveryMode mode;
           ^
      ./onvif/discoveryobj.h:39:32: error: expected ‘)’ before ‘mode’
           DiscoveryObj(DiscoveryMode mode, int _metadataVersion, char* _xaddr, char* _type, char* _scope, char* _endpoint);
      ravi@134.141.242.126:/home/ravi/cprog/OnvifDiscoveryLib/>make
      g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -std=c++11  -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -o discoverythread.o onvif/discoverythread.cpp
      In file included from onvif/discoverythread.cpp:2:0:
      ./onvif/discoveryobj.h:10:1: error: expected constructor, destructor, or type conversion before ‘enum’
       enum DiscoveryMode{
       ^
      ./onvif/discoveryobj.h:31:5: error: ‘DiscoveryMode’ does not name a type
           DiscoveryMode mode;
           ^
      ./onvif/discoveryobj.h:39:32: error: expected ‘)’ before ‘mode’
           DiscoveryObj(DiscoveryMode mode, int _metadataVersion, char* _xaddr, char* _type, char* _scope, char* _endpoint);
                                      ^
      Makefile:299: recipe for target 'discoverythread.o' failed
      make: *** [discoverythread.o] Error 1
      
      // File name: discoveryobj.h
      
      #ifndef prob_H
      #define prob_H
      
      #include <QVector>
      #include <QString>
      #include <QObject>
      #include "descdevice.h"
      #include "discoverythread.h"
      
      enum DiscoveryMode{
          SERVER_MODE, CLIENT_MODE
      };
      
      class DiscoveryObj: public QObject{
      
          Q_OBJECT   
      signals:
          void discoveredDevice(DescDevice);
      
      private:
          DiscoveryThread discoveryThread;
      
      public:
      //    const int   _metadataVersion = 1;
      //    const char* _xaddr="http://localhost/service";
      //    const char* _type="\"http://schemas.xmlsoap.org/ws/2006/02/devprof\":device";
      //    const char* _scope="scope";
      //    const char* _endpoint="urn";
      
      
          DiscoveryMode mode;
          static DiscoveryObj *theDiscovery;
          int   _metadataVersion;
          char* _xaddr;
          char* _type;
          char* _scope;
          char* _endpoint;
      
          DiscoveryObj(DiscoveryMode mode, int _metadataVersion, char* _xaddr, char* _type, char* _scope, char* _endpoint);
          ~DiscoveryObj();
      
          int sendProb();
          int sendHello();
          int sendBye();
      };
      
      #endif
      
      
      // Filename: discoverythread.h
      
      #ifndef MYTHREAD_H
      #define MYTHREAD_H
      #include <QThread>
      
      class DiscoveryThread : public QThread
      {
          const char* host = "239.255.255.250";
          int port = 3702;
      //    const int   _metadataVersion = 1;
      //    const char* _xaddr="http://localhost/service";
      //    const char* _type="\"http://schemas.xmlsoap.org/ws/2006/02/devprof\":device";
      //    const char* _scope="scope";
      //    const char* _endpoint="urn";
          Q_OBJECT
      public:
          DiscoveryThread();
      protected:
          void run();
      };
      
      #endif // MYTHREAD_H
      
      
      // File Name: descdevice.h
      
      #ifndef DESCDEVICE
      #define DESCDEVICE
      
      struct DescDevice{
          int metadataversion;
          QString types;
          QString xAddrs;
          QString scopes;
      };
      
      Q_DECLARE_METATYPE(DescDevice)
      
      #endif // DESCDEVICE
      

      can any one help me in understating what is wrong here?

      thanks

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @ravi2k18 My guess is that something is wrong in one of the two header files you're including in discoveryobj.h

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • R ravi2k18

        Hi,

        I am facing below build error while building the qt project.

        /home/ravi/> make
        g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -std=c++11  -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -o discoverythread.o onvif/discoverythread.cpp
        In file included from onvif/discoverythread.cpp:2:0:
        ./onvif/discoveryobj.h:10:1: error: expected constructor, destructor, or type conversion before ‘enum’
         enum DiscoveryMode{
         ^
        ./onvif/discoveryobj.h:31:5: error: ‘DiscoveryMode’ does not name a type
             DiscoveryMode mode;
             ^
        ./onvif/discoveryobj.h:39:32: error: expected ‘)’ before ‘mode’
             DiscoveryObj(DiscoveryMode mode, int _metadataVersion, char* _xaddr, char* _type, char* _scope, char* _endpoint);
        ravi@134.141.242.126:/home/ravi/cprog/OnvifDiscoveryLib/>make
        g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -std=c++11  -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -o discoverythread.o onvif/discoverythread.cpp
        In file included from onvif/discoverythread.cpp:2:0:
        ./onvif/discoveryobj.h:10:1: error: expected constructor, destructor, or type conversion before ‘enum’
         enum DiscoveryMode{
         ^
        ./onvif/discoveryobj.h:31:5: error: ‘DiscoveryMode’ does not name a type
             DiscoveryMode mode;
             ^
        ./onvif/discoveryobj.h:39:32: error: expected ‘)’ before ‘mode’
             DiscoveryObj(DiscoveryMode mode, int _metadataVersion, char* _xaddr, char* _type, char* _scope, char* _endpoint);
                                        ^
        Makefile:299: recipe for target 'discoverythread.o' failed
        make: *** [discoverythread.o] Error 1
        
        // File name: discoveryobj.h
        
        #ifndef prob_H
        #define prob_H
        
        #include <QVector>
        #include <QString>
        #include <QObject>
        #include "descdevice.h"
        #include "discoverythread.h"
        
        enum DiscoveryMode{
            SERVER_MODE, CLIENT_MODE
        };
        
        class DiscoveryObj: public QObject{
        
            Q_OBJECT   
        signals:
            void discoveredDevice(DescDevice);
        
        private:
            DiscoveryThread discoveryThread;
        
        public:
        //    const int   _metadataVersion = 1;
        //    const char* _xaddr="http://localhost/service";
        //    const char* _type="\"http://schemas.xmlsoap.org/ws/2006/02/devprof\":device";
        //    const char* _scope="scope";
        //    const char* _endpoint="urn";
        
        
            DiscoveryMode mode;
            static DiscoveryObj *theDiscovery;
            int   _metadataVersion;
            char* _xaddr;
            char* _type;
            char* _scope;
            char* _endpoint;
        
            DiscoveryObj(DiscoveryMode mode, int _metadataVersion, char* _xaddr, char* _type, char* _scope, char* _endpoint);
            ~DiscoveryObj();
        
            int sendProb();
            int sendHello();
            int sendBye();
        };
        
        #endif
        
        
        // Filename: discoverythread.h
        
        #ifndef MYTHREAD_H
        #define MYTHREAD_H
        #include <QThread>
        
        class DiscoveryThread : public QThread
        {
            const char* host = "239.255.255.250";
            int port = 3702;
        //    const int   _metadataVersion = 1;
        //    const char* _xaddr="http://localhost/service";
        //    const char* _type="\"http://schemas.xmlsoap.org/ws/2006/02/devprof\":device";
        //    const char* _scope="scope";
        //    const char* _endpoint="urn";
            Q_OBJECT
        public:
            DiscoveryThread();
        protected:
            void run();
        };
        
        #endif // MYTHREAD_H
        
        
        // File Name: descdevice.h
        
        #ifndef DESCDEVICE
        #define DESCDEVICE
        
        struct DescDevice{
            int metadataversion;
            QString types;
            QString xAddrs;
            QString scopes;
        };
        
        Q_DECLARE_METATYPE(DescDevice)
        
        #endif // DESCDEVICE
        

        can any one help me in understating what is wrong here?

        thanks

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @ravi2k18 Q_OBJECT must be the first line after { in your class!

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        2
        • R ravi2k18

          Hi,

          I am facing below build error while building the qt project.

          /home/ravi/> make
          g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -std=c++11  -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -o discoverythread.o onvif/discoverythread.cpp
          In file included from onvif/discoverythread.cpp:2:0:
          ./onvif/discoveryobj.h:10:1: error: expected constructor, destructor, or type conversion before ‘enum’
           enum DiscoveryMode{
           ^
          ./onvif/discoveryobj.h:31:5: error: ‘DiscoveryMode’ does not name a type
               DiscoveryMode mode;
               ^
          ./onvif/discoveryobj.h:39:32: error: expected ‘)’ before ‘mode’
               DiscoveryObj(DiscoveryMode mode, int _metadataVersion, char* _xaddr, char* _type, char* _scope, char* _endpoint);
          ravi@134.141.242.126:/home/ravi/cprog/OnvifDiscoveryLib/>make
          g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -std=c++11  -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -o discoverythread.o onvif/discoverythread.cpp
          In file included from onvif/discoverythread.cpp:2:0:
          ./onvif/discoveryobj.h:10:1: error: expected constructor, destructor, or type conversion before ‘enum’
           enum DiscoveryMode{
           ^
          ./onvif/discoveryobj.h:31:5: error: ‘DiscoveryMode’ does not name a type
               DiscoveryMode mode;
               ^
          ./onvif/discoveryobj.h:39:32: error: expected ‘)’ before ‘mode’
               DiscoveryObj(DiscoveryMode mode, int _metadataVersion, char* _xaddr, char* _type, char* _scope, char* _endpoint);
                                          ^
          Makefile:299: recipe for target 'discoverythread.o' failed
          make: *** [discoverythread.o] Error 1
          
          // File name: discoveryobj.h
          
          #ifndef prob_H
          #define prob_H
          
          #include <QVector>
          #include <QString>
          #include <QObject>
          #include "descdevice.h"
          #include "discoverythread.h"
          
          enum DiscoveryMode{
              SERVER_MODE, CLIENT_MODE
          };
          
          class DiscoveryObj: public QObject{
          
              Q_OBJECT   
          signals:
              void discoveredDevice(DescDevice);
          
          private:
              DiscoveryThread discoveryThread;
          
          public:
          //    const int   _metadataVersion = 1;
          //    const char* _xaddr="http://localhost/service";
          //    const char* _type="\"http://schemas.xmlsoap.org/ws/2006/02/devprof\":device";
          //    const char* _scope="scope";
          //    const char* _endpoint="urn";
          
          
              DiscoveryMode mode;
              static DiscoveryObj *theDiscovery;
              int   _metadataVersion;
              char* _xaddr;
              char* _type;
              char* _scope;
              char* _endpoint;
          
              DiscoveryObj(DiscoveryMode mode, int _metadataVersion, char* _xaddr, char* _type, char* _scope, char* _endpoint);
              ~DiscoveryObj();
          
              int sendProb();
              int sendHello();
              int sendBye();
          };
          
          #endif
          
          
          // Filename: discoverythread.h
          
          #ifndef MYTHREAD_H
          #define MYTHREAD_H
          #include <QThread>
          
          class DiscoveryThread : public QThread
          {
              const char* host = "239.255.255.250";
              int port = 3702;
          //    const int   _metadataVersion = 1;
          //    const char* _xaddr="http://localhost/service";
          //    const char* _type="\"http://schemas.xmlsoap.org/ws/2006/02/devprof\":device";
          //    const char* _scope="scope";
          //    const char* _endpoint="urn";
              Q_OBJECT
          public:
              DiscoveryThread();
          protected:
              void run();
          };
          
          #endif // MYTHREAD_H
          
          
          // File Name: descdevice.h
          
          #ifndef DESCDEVICE
          #define DESCDEVICE
          
          struct DescDevice{
              int metadataversion;
              QString types;
              QString xAddrs;
              QString scopes;
          };
          
          Q_DECLARE_METATYPE(DescDevice)
          
          #endif // DESCDEVICE
          

          can any one help me in understating what is wrong here?

          thanks

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @ravi2k18 said in error: expected constructor, destructor, or type conversion before ‘enum’ while building in linux with make:

          DiscoveryThread();

          you're derving from QThread/QObject make this a proper constructor with base class initialisation


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          2

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved