__int64 question
-
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);
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...
-
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...
dooooooooooouuuuuuuuuuughhhhhhhhhhh !!!!!!!!! Thanks for pointing my stupidity, that's an excellent proof for why you should not skip lunch. Shay
-
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
-
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)
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)
-
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)
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!
-
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
-
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)
I finally beat you to an answer.... you're slacking off!!;P onwards and upwards...
-
I finally beat you to an answer.... you're slacking off!!;P onwards and upwards...
My apologies. I was working on an article that had me sidetracked.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
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!
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 -
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