Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. __int64 question

__int64 question

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionc++
15 Posts 8 Posters 1 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.
  • S Shay Harel

    Thanks, but one more thing When I use ar.Write or ar.Read, it looks for a pointer to a buffer. It looks like when I read, it read more that needed, even though I specified 64 in the second paramter. So.... If I need to serialize a 64 bit number using write, should it be: ar.Write (&number,64)? and read back: ar.Read (&number,64);

    B Offline
    B Offline
    basementman
    wrote on last edited by
    #6

    first off, your __int64 variable is NOT 64 bytes long. It is 64 BITS long, which, when divided by 8 bits per byte, is 8 bytes. So, you should pass 8 for the second param ( or sizeof(__int64) ). ar.Write(&number,8); -- or -- ar.Write(&number,sizeof(__int64));  onwards and upwards...

    S 1 Reply Last reply
    0
    • B basementman

      first off, your __int64 variable is NOT 64 bytes long. It is 64 BITS long, which, when divided by 8 bits per byte, is 8 bytes. So, you should pass 8 for the second param ( or sizeof(__int64) ). ar.Write(&number,8); -- or -- ar.Write(&number,sizeof(__int64));  onwards and upwards...

      S Offline
      S Offline
      Shay Harel
      wrote on last edited by
      #7

      dooooooooooouuuuuuuuuuughhhhhhhhhhh !!!!!!!!! Thanks for pointing my stupidity, that's an excellent proof for why you should not skip lunch. Shay

      1 Reply Last reply
      0
      • B BlackDice

        Try using the LARGE_INTEGER data type. Text between asterisks is text quoted directly from the MSDN documentation on the data type *********************** LARGE_INTEGER The LARGE_INTEGER structure is used to represent a 64-bit signed integer value. Note Your C compiler may support 64-bit integers natively. For example, Microsoft® Visual C++® supports the __int64 sized integer type. For more information, see the documentation included with your C compiler. typedef union union { struct { DWORD LowPart; LONG HighPart; }; LONGLONG QuadPart; } LARGE_INTEGER, *PLARGE_INTEGER; ************************************* hope this helped! If it's broken, I probably did it bdiamond

        S Offline
        S Offline
        Steve S
        wrote on last edited by
        #8

        Darn. Beat me to it. I was going to suggest doing something similar and then using the standard CArchive operators on the smaller bits. Steve S

        B 1 Reply Last reply
        0
        • S Shay Harel

          Hi, I just upgraded a portion of my code from int to __int64, everything looked fine but the only problem is that it looks like this data type could not be serialized..... Anyone know a 64bit data type in MFC that can be serialized ? Shay\ error C2593: 'operator <<' is ambiguous error C2679: binary '>>' : no operator defined which takes a right-hand operand of type '__int64' (or there is no acceptable conversion)

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #9

          I once wrote an extension to the CArchive class that handled serialization of the __int64 type. I can send it to you if you'd like.


          "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

          S B 2 Replies Last reply
          0
          • D David Crow

            I once wrote an extension to the CArchive class that handled serialization of the __int64 type. I can send it to you if you'd like.


            "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

            S Offline
            S Offline
            Shay Harel
            wrote on last edited by
            #10

            First of all, you can send it, it never hurts to share someone elses wisdom. Second, I already utilized the Write/Read functions of the archive. Thanks!

            J 1 Reply Last reply
            0
            • S Steve S

              Darn. Beat me to it. I was going to suggest doing something similar and then using the standard CArchive operators on the smaller bits. Steve S

              B Offline
              B Offline
              BlackDice
              wrote on last edited by
              #11

              well I'm glad to see I beat somebody to something for once:cool: If it's broken, I probably did it bdiamond

              1 Reply Last reply
              0
              • D David Crow

                I once wrote an extension to the CArchive class that handled serialization of the __int64 type. I can send it to you if you'd like.


                "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

                B Offline
                B Offline
                basementman
                wrote on last edited by
                #12

                I finally beat you to an answer.... you're slacking off!!;P  onwards and upwards...

                D 1 Reply Last reply
                0
                • B basementman

                  I finally beat you to an answer.... you're slacking off!!;P  onwards and upwards...

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #13

                  My apologies. I was working on an article that had me sidetracked.


                  "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

                  1 Reply Last reply
                  0
                  • S Shay Harel

                    First of all, you can send it, it never hurts to share someone elses wisdom. Second, I already utilized the Write/Read functions of the archive. Thanks!

                    J Offline
                    J Offline
                    jbarton
                    wrote on last edited by
                    #14

                    I prefer to write a global operator>> and operator<< for datatypes like this, so that I can still use the syntax of a stream operator with the archive. CArchive& operator<<( CArchive& archive, __int64 value ) { archive.Write( &value, sizeof(__int64) ); return archive; } CArchive& operator>>( CArchive& archive, __int64 value ) { archive.Read( &value, sizeof(__int64) ); return archive; } This works for simple data types. I use this for bool as VC6.0 doesn't implement serialization for bool, but this should also work fine for __int64. Best regards, John

                    K 1 Reply Last reply
                    0
                    • J jbarton

                      I prefer to write a global operator>> and operator<< for datatypes like this, so that I can still use the syntax of a stream operator with the archive. CArchive& operator<<( CArchive& archive, __int64 value ) { archive.Write( &value, sizeof(__int64) ); return archive; } CArchive& operator>>( CArchive& archive, __int64 value ) { archive.Read( &value, sizeof(__int64) ); return archive; } This works for simple data types. I use this for bool as VC6.0 doesn't implement serialization for bool, but this should also work fine for __int64. Best regards, John

                      K Offline
                      K Offline
                      khb
                      wrote on last edited by
                      #15

                      Thanks for the tip! But don't forget to pass in the second parameter of operator>> by reference (__int64& value). Then it works perfectly! Regards Marcus

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups