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. QUdpSocket failed when make while QTcpSocket is fine in
Forum Updated to NodeBB v4.3 + New Features

QUdpSocket failed when make while QTcpSocket is fine in

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 414 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.
  • Q Offline
    Q Offline
    Quey
    wrote on last edited by
    #1

    I am working on an embedded linux 3.5.0-25 with qt-everywhere-opensource-src-4.6.3

    I have the dialog.h as:
    ........
    #include <QtNetwork>
    #include <QTcpSocket>
    #include <QUdpSocket>
    .......
    QTcpSocket *pSocketTcp;
    QUdpSocket *pSocketUdp;
    .......
    That will get error:

    error: ISO C++ forbids declaration of `QUdpSocket' with no type

    When I remarked QUdpSocket *pSocketUdp; line and keep the QTcpSocket *pSocketTcp; there, the make worked fine.

    I need help to make QUdpSocket work in my application.
    Thanks in advance.

    jsulmJ 1 Reply Last reply
    0
    • Q Quey

      I am working on an embedded linux 3.5.0-25 with qt-everywhere-opensource-src-4.6.3

      I have the dialog.h as:
      ........
      #include <QtNetwork>
      #include <QTcpSocket>
      #include <QUdpSocket>
      .......
      QTcpSocket *pSocketTcp;
      QUdpSocket *pSocketUdp;
      .......
      That will get error:

      error: ISO C++ forbids declaration of `QUdpSocket' with no type

      When I remarked QUdpSocket *pSocketUdp; line and keep the QTcpSocket *pSocketTcp; there, the make worked fine.

      I need help to make QUdpSocket work in my application.
      Thanks in advance.

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

      @Quey But the compiler does not complain about #include <QUdpSocket> ?

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

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        Quey
        wrote on last edited by
        #3

        @jsulm said in QUdpSocket failed when make while QTcpSocket is fine in:

        But the compiler does not complain about #include <QUdpSocket> ?

        It will compile fine as long as there is no variable QUdpSocket *pSocket;

        jsulmJ 1 Reply Last reply
        0
        • Q Quey

          @jsulm said in QUdpSocket failed when make while QTcpSocket is fine in:

          But the compiler does not complain about #include <QUdpSocket> ?

          It will compile fine as long as there is no variable QUdpSocket *pSocket;

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

          @Quey Just realised you're working with Qt 4.6.3 which very old (not even latest Qt 4 release).
          I suggest to check the content of the QUdpSocket header file.
          Also you can post the real code where this error message originates from. Can be that there is something wrong in another place than the "QUdpSocket *pSocketUdp;" line. Because the error suggests that you're actually trying to declare a variable named QUdpSocket.

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

          1 Reply Last reply
          1
          • Q Offline
            Q Offline
            Quey
            wrote on last edited by
            #5

            Thanks, I'll do some works for a much clear picture.

            1 Reply Last reply
            0
            • Q Offline
              Q Offline
              Quey
              wrote on last edited by
              #6

              @jsulm Thanks, it turned out that the QUdpSocket header file has directive as
              #ifndef QT_NO_UDPSOCKET

              remark this #if solves my problem, thanks.

              1 Reply Last reply
              1

              • Login

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