Byte Ordering MFC Serialization [Solved]
-
Does the serialization class CArchive automatically handle byte ordering differences on different platforms ? I have a class which i am serializing on an Big Endian platform but will be deserializing it on a little endian platform. Is there anything i need to watch out for ? The only bit of info i have managed to find on the net is this article http://www.drdobbs.com/184409538;jsessionid=T1RL5VK3F2RBFQE1GHPCKHWATMY32JVN?_requestid=488503[^] However it is a bit outdated. [Solution] OK for those who are interested, it seems as if CArchive does not do any byte swapping at all. The reason being is that all versions of windows run the same endianess.. http://social.msdn.microsoft.com/Forums/en/windowsmobiledev/thread/04c92ef9-e38e-415f-8958-ec9f7c196fd3[^] The two items in the CArchive class that would have anything to do with byte swapping actually do nothing at all. i.e.
CArchive::IsByteSwapping
andCArchive::bNoByteSwap
Cheers Garth I don't really care whether or not i really care or not.
modified on Tuesday, March 2, 2010 6:29 AM
-
Does the serialization class CArchive automatically handle byte ordering differences on different platforms ? I have a class which i am serializing on an Big Endian platform but will be deserializing it on a little endian platform. Is there anything i need to watch out for ? The only bit of info i have managed to find on the net is this article http://www.drdobbs.com/184409538;jsessionid=T1RL5VK3F2RBFQE1GHPCKHWATMY32JVN?_requestid=488503[^] However it is a bit outdated. [Solution] OK for those who are interested, it seems as if CArchive does not do any byte swapping at all. The reason being is that all versions of windows run the same endianess.. http://social.msdn.microsoft.com/Forums/en/windowsmobiledev/thread/04c92ef9-e38e-415f-8958-ec9f7c196fd3[^] The two items in the CArchive class that would have anything to do with byte swapping actually do nothing at all. i.e.
CArchive::IsByteSwapping
andCArchive::bNoByteSwap
Cheers Garth I don't really care whether or not i really care or not.
modified on Tuesday, March 2, 2010 6:29 AM
Well, you may perform a little test. :) [added] I guess the outdated article's content is still true (at least for compatibility reasons). [/added]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Well, you may perform a little test. :) [added] I guess the outdated article's content is still true (at least for compatibility reasons). [/added]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Well....I'm just taking the easy way out ;) Actually i was hoping someone had already performed a little test already. And i also don't currently have access to the little endian platform.
Cheers Garth I don't really care whether or not i really care or not.
-
Well....I'm just taking the easy way out ;) Actually i was hoping someone had already performed a little test already. And i also don't currently have access to the little endian platform.
Cheers Garth I don't really care whether or not i really care or not.
Garth Watkins wrote:
And i also don't currently have access to the little endian platform.
You don't need: just see, with you fovourite hex editor, if the binary file is properly 'little-endianned'... :rolleyes:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Garth Watkins wrote:
And i also don't currently have access to the little endian platform.
You don't need: just see, with you fovourite hex editor, if the binary file is properly 'little-endianned'... :rolleyes:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]How is that going to help ? Lets say for instance i serialize class to a file. I then open the file in a hex editor. That's going to tell me what format (Little Endian/Big Endian) the CArchive class saves data in. It's not going to tell me whether or not it gets restored in the proper way when deserializing it on another platform that has a different byte order.
Cheers Garth I don't really care whether or not i really care or not.
-
How is that going to help ? Lets say for instance i serialize class to a file. I then open the file in a hex editor. That's going to tell me what format (Little Endian/Big Endian) the CArchive class saves data in. It's not going to tell me whether or not it gets restored in the proper way when deserializing it on another platform that has a different byte order.
Cheers Garth I don't really care whether or not i really care or not.
Garth Watkins wrote:
That's going to tell me what format (Little Endian/Big Endian) the CArchive class saves data in. It's not going to tell me whether or not it gets restored in the proper way when deserializing it on another platform that has a different byte order.
It should serialize it in little-endian format. That way you may be pretty confident it will work on other platforms (as quick-test result 'pretty confident' is good, anyway, I suppose checking the endianess is a bit painful). I would say (based on Dr.Dobb's article): if you don't make mistakes, it will work. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]