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

QDatastream

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 3.1k Views 1 Watching
  • 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
    IanBorn
    wrote on last edited by
    #1

    On Linux(64bit g++), I have :
    @
    typedef struct
    {
    qint64 x,y;
    bool break_flag;
    } PNT;
    @
    and on Vista(mingwc++32) I have
    @
    typedef struct
    {
    quint32 x,y;
    bool break_flag;
    } PNT;
    @
    Will the serialized data using QDatastream be protable between Linix and Window?

    Thanks.

    [Edit] Code wrappers added; koahnig

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

      Qt is binary compatible across platforms but you still have to use the same data types, and in your particular case you have 8 vs 4 byte integers. Why do you have different types to begin with? I could see an issue if you use plain integers which vary with the architecture "width" they were built for but in your case you explicitly define different data types, not the compiler.

      Since you are not using those to hold architecture width specific data but coordinates, you can conform either one of the solutions to gain compatibility, for example using 32 bit integers in both cases, since the 32 bit build will have a harder time working with 64 bit integers and you hardly need that much precision.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        koahnig
        wrote on last edited by
        #3

        Please remember next time to use "code wrappers ":http://developer.qt.nokia.com/wiki/ForumHelp#e3f82045ad0f480d3fb9e0ac2d58fb01

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        0
        • I Offline
          I Offline
          IanBorn
          wrote on last edited by
          #4

          There is a reason(not a good one) for this. When I started to write this program, I wasn't thinking about
          protable across all platforms. I started on Vista and used integer instead of qint32. So, a lots of calculations and manipulation are using int(4 bytes). the program and data are portable between Linux(32 bits) and Vista. Therefore I have no choice but to declare all integer to either qint32 or qint64.
          Which one of the two(qint32 or qin64) will most likely give me less problem?

          1 Reply Last reply
          0
          • ? This user is from outside of this forum
            ? This user is from outside of this forum
            Guest
            wrote on last edited by
            #5

            The very reason Qt uses all those typedefs is to provide portability, because if you use plain ints the size is determined by the compiler.

            Just use qint32 in both cases, qint64 won't give you problems but will give you lower performance in 32bit builds and larger memory footprint. I really doubt you need 20 digit precision :)

            1 Reply Last reply
            0
            • I Offline
              I Offline
              IanBorn
              wrote on last edited by
              #6

              I almost forget one thing. Sometime, I use QPoint to exchange with my PNT struct like spnt.x=qpnt.x();
              It will work if qpnt.x>=0, but it won't work if it is negative. Oh well. I just used integer in my struct and then convert it to qint32 before serialize it. And do the other way around after desrialization.

              Thanks.

              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