问题
We have a 32-bit C++ GUI application running on 32 bit windows 7. We are planning to migrate our server with C++ apps to 64-bit linux. We have noticed that long types are larger in 64 bit. This will be incompatible with the client-server message passing from 64-bit to 32-bit. What is a good way to solve this incompatibility? Do we need to change the code? How? or Do we use a third party software to do the conversion? What software is it?
回答1:
That's why there is the standardized int32_t and uint32_t types etc., so you could specifically select type depending on your needs.
It might be quite a lot of work to replace all long
types to int32_t
in all structures you send, especially if it's a big project, but you (hopefully) only have to do it once. Another way of solving this problem is to serialize the data into a text-format and then deserialize it on the receiving side, this has the big advantage that it will make the communication almost completely platform independent.
来源:https://stackoverflow.com/questions/20394060/how-can-a-32-bit-client-communicate-with-a-64-bit-server-if-long-type-is-passed