32bit vs 64bit

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.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s