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.1k 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 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.

    JonBJ 1 Reply Last reply
    0
    • JonBJ JonB

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

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 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

      JonBJ 1 Reply Last reply
      1
      • I ikuris

        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.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on 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?

        Christian EhrlicherC I 2 Replies Last reply
        0
        • JonBJ JonB

          @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?

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 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

          JonBJ 1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            QDataStream has no overload for uint64_t, only for quint64.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on 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?

            Christian EhrlicherC 1 Reply Last reply
            0
            • JonBJ JonB

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

              Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 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

              JonBJ 1 Reply Last reply
              1
              • JonBJ JonB

                @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 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
                • Christian EhrlicherC Christian Ehrlicher

                  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.

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on 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 last edited by
                    #8

                    @Christian-Ehrlicher

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

                    Christian EhrlicherC 1 Reply Last reply
                    0
                    • I ikuris has marked this topic as solved on
                    • I ikuris

                      @Christian-Ehrlicher

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

                      Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on 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

                      • Login

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