C++ Portability General Question

If I design software under a POSIX environment and I use specific POSIX software, how "portable" am I making my program?

If a client needs the software to run on Windows, then is there an easy port between two very different platforms?
Don't leave portability as an afterthought. Consider your requirements and document your goals. If platform independence is one of them, use the proper libraries.

To answer your specific question, how [un]portable the system becomes is directly related to the library and its usage. There are alternatives such as virtualization and emulation, if it is too late. Do a little research on VMware Player and Cygwin for examples of the above two strategies.
It should be fairly easy to port between posix and windows as long as you use portable libraries. Use the standard libraries to the full. Use libraries like boost. If you need what you write to run on both windows and posix then you should compile on both from the beginning. Then you will know what is and what is not portable as you go.
If I design software under a POSIX environment and I use specific POSIX software, how "portable" am I making my program?
Nearly not at all.

A few thoughts on portability:
1. Don't reinvent the wheel. There's hundreds of libraries out there, and many (most?) of them offer some abstraction from the system, which is one of the pillars of portability.
2. Abstract and encapsulate. If you have to use system calls, don't leave them sprinkled all over the program. Put them in functions. This will make it easier to write conditionally compiled code when (not if) the time comes. Also, make sure the functions reveal as little as possible about the underlying system, and that different versions of the same function have identical semantics (e.g. a function that opens a file for output should not, if the file already exists, fail under UNIX but truncate the file under Windows).
3. Like moorecm said, don't postpone portability. The bigger a project becomes, the harder it becomes to make it portable.
Thanks all! I'll keep this in mind.
Topic archived. No new replies allowed.