You can't be sure your app is portable unless you have the target platform to hand to test it. |
True, but you can certainly increase the portability probability.
On the high level, you just need to avoid any function call that isn't standard. If you need to do something that isn't standard, you use a portable library (e.g. instead of making windows by directly calling the WinAPI, using a GUI toolkit).
On the lower level, you have to avoid making assumptions about type sizes and endianness.
Finally, sometimes a library that's supposed to be portable behaves slightly differently on different platforms and you have to compensate by not using the unreliable feature. SDL_BlitSurface() gave me a surprise once when I tested my program on Linux.
Making something portable takes more than 5 minutes. |
Nah, not really.
On average, making an app portable doesn't take significantly longer than making it unportable.
By sticking with platform agnostic code, you can loose out on platform specific optimisations. |
But you can take advantage of them and still keep the application portable by writing different versions of the same code for different platforms.
More often than not, applications are unportable due to the author's shortsightedness or indifference, not because of any technical reasons.
The same applies to applications lacking Unicode support when it would be appropriate. Among the more annoying examples I know of are IrfanView, TotalCommander, and anything that comes out of Japan.