with preprocessor:
#ifdef _SUNOS
//code
#elseif _LINUX
//code
#elseif _HPUX
//code
#elseif _WIN32
//code
#else
#error OS not supported
#endif
How do i include different headers based on my OS?
http://stackoverflow.com/questions/6115711/how-do-i-include-different-headers-based-on-my-os
with preprocessor:
#ifdef _SUNOS
//code
#elseif _LINUX
//code
#elseif _HPUX
//code
#elseif _WIN32
//code
#else
#error OS not supported
#endif
What is the recommended way to organize platform specific code in C++?
Make sure you don't use COMPILER specific extensions, or atleast stick to 1 SINGLE compiler(recommended: G++ which is cross platform)
Follow these first. Patterns are but means of organising code. Standard patterns allowed by a language theoretically remain the same across all platforms, so that shouldn't be a part of the problem
Use #ifdef MACROS to code platform specific path to files, platform specific libraries for networking etc