Portable C++ is quite ambiguous.
However, if you want to achieve portability, only use the Standard Library of C++, and no platform specific code (like read
, write
syscalls on Linux), no compiler specific intrinsics (like GCC's C / C++ extensions), or inline assembly for a specific CPU.
Keep in mind, that even this might not be "portable". You can compile C++ for a wide variety of platforms (including embedded), and not all of these platforms might ship with a Standard C++ library, or have a compiler supporting the latest and greatest C++ features (C++11, C++14 comes in mind).
True portability can not be achieved, you can, however, achieve portability for the most common platforms, or commit to support these X platforms, and build a platform specific solution for each of them (which is a considerable amount of work, and results in a lot of #ifdef OS1
code).