Code portability basically refers to making source code able to compile on different platform without making any changes in source code.
Non-portable code introduces problems like maintenance of different versions, reduces readability, reduces understanding of code etc...
Efforts needs to make legacy or old source code portable, can really make you feel lost in this big programming ocean. So, the best policy is to keep portability into account while writing code, it saves lots of time and efforts on rework. Big question now is - "How to write portable code?".Our source code should be compatible with different environment like different processor, different OS, different version of libraries etc... In this post we would focus on basic tips need to be kept in mind while writing code.
Like some compiler support variable scope limited to for() while some compiler dont.
Don't prefer writing code as below (Non-portable code).
for(int i ; ;)
//do some thing