I am writing a system to allow remote procedure calls. I want to make sure that it would be platform independent as possible, so that if I pack an integer on a x86-64 machine (4 or 8 bytes), the generated unpacking code on the target, which can be a 8051 (int is 2 bytes) will still be able to correctly handle this. So my issue is that "int" and "long" have different meaning on different platforms. I thought of writing a generic integer packer (and support other types) than accept a void pointer and the width of the data pointed to. It will then call htonl() onto the memory location and copy it to the buffer. The unpacker needs to do the other way around, but I am not entirely sure what to do if the data does not fit the available native type. Any thought will be much appreciated!