I don't know why you are downvoted, but this is very important.
Never send anything "on the wire" (or to a file) unless you know its exact size and endianness.
However for cross platform support using size_t in an API (as in what is exposed via .dll or .so) is a must. It's exactly the correct way to write cross platform code.
I don't know why you are downvoted, but this is very important.
Never send anything "on the wire" (or to a file) unless you know its exact size and endianness.