I wanted to reply in the thread, but it was archived, so here goes:
The best way to introduce code portability is while coding. |
As opposed to introducing it while juggling?
Non-portable code introduces problems like maintenance of different versions, reduces readability, reduces understanding of code etc... |
Huh? How exactly does portability increase readability?
Also, the first phrase is completely backwards. It's portable code that often requires several versions. Code that's meant to work for a single platform needs a single version, while it's not always possible to use the same code for different platforms.
For example, suppose you're writing a library to abstract file system operations. The function that creates a directory will need one version for Windows, another for POSIX, etc.
So, the best policy is to keep portability into account while writing code, it saves lots of time |
Portability
takes time. If, for whatever reason, the project doesn't need to be portable, then making it portable is a pure waste of time. You might argue that it's easier to make it portable early on, than the requirements changing later and having to do a lot of rewriting, my answer to which is YAGNI.
2) Don't use specific system constant. |
What? Define "system constant".
3) System file/folder path notation may vary on different platform. |
But forward slash and relative paths are universally accepted.
5) Always write default statement in switch case. |
What does that have to do with portability?
6) Always specify return type for functions. |
Wait. Is this for C, C++, or code that can be compiled by either compiler? The shortest valid C89 program is
main(){}
. C99 issues a warning.
7) Always specify type with static variables.
8) Always take care of scope of variable.
10) Take care of include depth for header files and also for file code size. |
What's any of that supposed to mean?
Finally,
https://developer.mozilla.org/en/C___Portability_Guide
Not all the points in that guide will be relevant for everyone, but it's good nonetheless.
Also, partly relevant to portability:
http://www.jorgon.freeserve.co.uk/GoasmHelp/Unicode.htm