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. Question regarding Big/Little endian
QtWS25 Last Chance

Question regarding Big/Little endian

Scheduled Pinned Locked Moved Solved General and Desktop
qtnetworklinuxwindows
4 Posts 3 Posters 2.6k 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.
  • D Offline
    D Offline
    DRoscoe
    wrote on 23 Sept 2016, 14:07 last edited by
    #1

    We recently ran into an issue running on an older PowerPC platform. All of our code assumes little-endian byte order, but the PowerPC is a big-endian platform by default, so we had some problems.

    I am writing some new socket code and want to ensure that I don't introduce any new issues. Looking at the Qt5.5 version of the Fortune client/server example, the fortune is streamed with a qint16 message header which specifies the size of the packet.

    How will this behave if I am communicating between a little-endian and a big-endian platform?

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VRonin
      wrote on 23 Sept 2016, 14:18 last edited by
      #2

      from http://doc.qt.io/qt-5/qdatastream.html

      A data stream is a binary stream of encoded information which is 100% independent of the host computer's operating system, CPU or byte order. For example, a data stream that is written by a PC under Windows can be read by a Sun SPARC running Solaris.

      You should be fine

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      D 1 Reply Last reply 23 Sept 2016, 14:20
      2
      • V VRonin
        23 Sept 2016, 14:18

        from http://doc.qt.io/qt-5/qdatastream.html

        A data stream is a binary stream of encoded information which is 100% independent of the host computer's operating system, CPU or byte order. For example, a data stream that is written by a PC under Windows can be read by a Sun SPARC running Solaris.

        You should be fine

        D Offline
        D Offline
        DRoscoe
        wrote on 23 Sept 2016, 14:20 last edited by
        #3

        @VRonin thanks!

        K 1 Reply Last reply 23 Sept 2016, 19:09
        0
        • D DRoscoe
          23 Sept 2016, 14:20

          @VRonin thanks!

          K Offline
          K Offline
          kshegunov
          Moderators
          wrote on 23 Sept 2016, 19:09 last edited by
          #4

          By default QDataStream uses big endian. You can change it manually, but do so on all platforms you want to deploy to/programs you're deploying. In any case you're fine as long as you stream your data with the appropriate operators and don't use writeRawData/readRawData or any reinterpret_cast "tricks".

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          1

          1/4

          23 Sept 2016, 14:07

          • Login

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