My last piece of work has to do with providing support for 32 bit applications. The entire software component was written and tested on a 64 bit platform and I was asked to make sure that it works with 32 bit apps also.
After some effort, I was able to make changes. This is what I learnt:
- size_t and time_t are not platform agnostic types. Because, they are derived from long which itself is different on 32 and 64 bit platforms. So, using them in the code should be prevented as far as possible. One can use uint32_t, uint64_t etc which specifies the width clearly.
- If possible, push the non-“8-byte-sized” fields (sorry for a bad paraphrasing) down the structure. This can help prevent some padding problems, which otherwise would show some surprising effects on 32 bit platforms.