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. QDataStream >> uin64_t
Forum Updated to NodeBB v4.3 + New Features

QDataStream >> uin64_t

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 1.2k 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.
  • I Offline
    I Offline
    ikuris
    wrote on 14 Mar 2023, 17:25 last edited by
    #1

    Hello, I do have a function like this

    void MainWindow::bttnClc()
    {
        uint64_t it3;
        QByteArray byte;
        QDataStream raw(&byte, QIODevice::ReadOnly);
        raw.setFloatingPointPrecision(QDataStream::DoublePrecision);
        raw.setByteOrder(QDataStream::ByteOrder::LittleEndian);
    
        raw.device()->seek(0);
    
        raw >> it3;
    
    }
    

    It is just an example but when I try to compile it on WSL2 with cmake I get the given error

    error: no match for ‘operator>>’ (operand types are ‘QDataStream’ and ‘uint64_t’ {aka ‘long unsigned int’})

    When I looked over it I saw there is no uint implementation of >> in QDataStream.cpp.

    MY question is why is this code works on Windows and not working on Linux, How to fix this error without changing the code or do I have to change the code?

    Thank you for your time.

    J 1 Reply Last reply 14 Mar 2023, 19:12
    0
    • J JonB
      14 Mar 2023, 19:23

      @Christian-Ehrlicher
      What is the typical definition for uint64_t, and where does it come from? How would it differ from quint64?

      C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 14 Mar 2023, 19:33 last edited by
      #5

      qglobal.h:
      msvc: typedef unsigned __int64 quint64; /* 64 bit unsigned /
      other: typedef unsigned long long quint64; /
      64 bit unsigned */

      cstdint or whereever the depths of the standard includes.
      gcc: typedef unsigned long int __uint64_t;
      typedef __uint64_t uint64_t;

      unsigned long long != unsigned long int I would guess.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      J 1 Reply Last reply 14 Mar 2023, 19:38
      1
      • I ikuris
        14 Mar 2023, 17:25

        Hello, I do have a function like this

        void MainWindow::bttnClc()
        {
            uint64_t it3;
            QByteArray byte;
            QDataStream raw(&byte, QIODevice::ReadOnly);
            raw.setFloatingPointPrecision(QDataStream::DoublePrecision);
            raw.setByteOrder(QDataStream::ByteOrder::LittleEndian);
        
            raw.device()->seek(0);
        
            raw >> it3;
        
        }
        

        It is just an example but when I try to compile it on WSL2 with cmake I get the given error

        error: no match for ‘operator>>’ (operand types are ‘QDataStream’ and ‘uint64_t’ {aka ‘long unsigned int’})

        When I looked over it I saw there is no uint implementation of >> in QDataStream.cpp.

        MY question is why is this code works on Windows and not working on Linux, How to fix this error without changing the code or do I have to change the code?

        Thank you for your time.

        J Offline
        J Offline
        JonB
        wrote on 14 Mar 2023, 19:12 last edited by JonB
        #2

        @ikuris
        There is QDataStream &QDataStream::operator<<(quint64 i). And for uint64 https://doc.qt.io/qt-6/qtglobal.html#quint64-typedef defines

        Typedef for unsigned long long int. This type is guaranteed to be 64-bit on all platforms supported by Qt.

        Would have thought that would work. Might depend on compiler or platform. I note your error message says

        ‘uint64_t’ {aka ‘long unsigned int’}

        which differs from unsigned long long int?

        Is uint64_t defined in a C++ standard library? I would investigate how uint64_t is not the same as quint64. And how ‘uint64_t’ {aka ‘long unsigned int’} does not match any of the QDataStream:operator<< integer overloads? Actually, verify what happens in the WSL2 case with quint64 here?

        C I 2 Replies Last reply 14 Mar 2023, 19:18
        0
        • J JonB
          14 Mar 2023, 19:12

          @ikuris
          There is QDataStream &QDataStream::operator<<(quint64 i). And for uint64 https://doc.qt.io/qt-6/qtglobal.html#quint64-typedef defines

          Typedef for unsigned long long int. This type is guaranteed to be 64-bit on all platforms supported by Qt.

          Would have thought that would work. Might depend on compiler or platform. I note your error message says

          ‘uint64_t’ {aka ‘long unsigned int’}

          which differs from unsigned long long int?

          Is uint64_t defined in a C++ standard library? I would investigate how uint64_t is not the same as quint64. And how ‘uint64_t’ {aka ‘long unsigned int’} does not match any of the QDataStream:operator<< integer overloads? Actually, verify what happens in the WSL2 case with quint64 here?

          C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 14 Mar 2023, 19:18 last edited by
          #3

          QDataStream has no overload for uint64_t, only for quint64.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          J 1 Reply Last reply 14 Mar 2023, 19:23
          0
          • C Christian Ehrlicher
            14 Mar 2023, 19:18

            QDataStream has no overload for uint64_t, only for quint64.

            J Offline
            J Offline
            JonB
            wrote on 14 Mar 2023, 19:23 last edited by JonB
            #4

            @Christian-Ehrlicher
            What is the typical definition for uint64_t, and where does it come from? How would it differ from quint64?

            C 1 Reply Last reply 14 Mar 2023, 19:33
            0
            • J JonB
              14 Mar 2023, 19:23

              @Christian-Ehrlicher
              What is the typical definition for uint64_t, and where does it come from? How would it differ from quint64?

              C Offline
              C Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 14 Mar 2023, 19:33 last edited by
              #5

              qglobal.h:
              msvc: typedef unsigned __int64 quint64; /* 64 bit unsigned /
              other: typedef unsigned long long quint64; /
              64 bit unsigned */

              cstdint or whereever the depths of the standard includes.
              gcc: typedef unsigned long int __uint64_t;
              typedef __uint64_t uint64_t;

              unsigned long long != unsigned long int I would guess.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              J 1 Reply Last reply 14 Mar 2023, 19:38
              1
              • J JonB
                14 Mar 2023, 19:12

                @ikuris
                There is QDataStream &QDataStream::operator<<(quint64 i). And for uint64 https://doc.qt.io/qt-6/qtglobal.html#quint64-typedef defines

                Typedef for unsigned long long int. This type is guaranteed to be 64-bit on all platforms supported by Qt.

                Would have thought that would work. Might depend on compiler or platform. I note your error message says

                ‘uint64_t’ {aka ‘long unsigned int’}

                which differs from unsigned long long int?

                Is uint64_t defined in a C++ standard library? I would investigate how uint64_t is not the same as quint64. And how ‘uint64_t’ {aka ‘long unsigned int’} does not match any of the QDataStream:operator<< integer overloads? Actually, verify what happens in the WSL2 case with quint64 here?

                I Offline
                I Offline
                ikuris
                wrote on 14 Mar 2023, 19:35 last edited by
                #6

                @JonB said in QDataStream >> uin64_t:

                as quint64. And how ‘uint64_t’ {aka ‘long unsigned int’} does

                uint64_t defined in <cstdint>. It does compile as expected when uint64_t becomes quint64.

                1 Reply Last reply
                0
                • C Christian Ehrlicher
                  14 Mar 2023, 19:33

                  qglobal.h:
                  msvc: typedef unsigned __int64 quint64; /* 64 bit unsigned /
                  other: typedef unsigned long long quint64; /
                  64 bit unsigned */

                  cstdint or whereever the depths of the standard includes.
                  gcc: typedef unsigned long int __uint64_t;
                  typedef __uint64_t uint64_t;

                  unsigned long long != unsigned long int I would guess.

                  J Offline
                  J Offline
                  JonB
                  wrote on 14 Mar 2023, 19:38 last edited by
                  #7

                  @Christian-Ehrlicher said in QDataStream >> uin64_t:

                  unsigned long long != unsigned long int I would guess.

                  Interesting.

                  1 Reply Last reply
                  0
                  • I Offline
                    I Offline
                    ikuris
                    wrote on 14 Mar 2023, 19:47 last edited by
                    #8

                    @Christian-Ehrlicher

                    So this is the reason why it does compile on Windows ? Thank you.

                    C 1 Reply Last reply 15 Mar 2023, 06:19
                    0
                    • I ikuris has marked this topic as solved on 14 Mar 2023, 20:22
                    • I ikuris
                      14 Mar 2023, 19:47

                      @Christian-Ehrlicher

                      So this is the reason why it does compile on Windows ? Thank you.

                      C Offline
                      C Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on 15 Mar 2023, 06:19 last edited by
                      #9

                      @ikuris said in QDataStream >> uin64_t:

                      So this is the reason why it does compile on Windows

                      Already explained:

                      unsigned long long != unsigned long int

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      1 Reply Last reply
                      0

                      4/9

                      14 Mar 2023, 19:23

                      • Login

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