Portable code is compilable on multiple platforms without changing anything in the source.
In this tutorial I will explain the way I do this.
The precompiler carries some constants, from this you are able to find out which platform the compiler is running on.
Because it's such little code I will just completely post it here:
//detect Mac OS-X
#if (defined(__MACH__))
//code for Mac platform, __Apple__ can also be used but that can result in problems
#elif defined (__linux__)
//code for Linux platform
#elif defined (_WIN32)
//code for Windows platform (also for 64 bit)
#else
//unknown platform
#endif
Or, if the same code is being used for multiple Operating Systems:
#if (defined(__MACH__))|| defined (__linux__)
//code for Mac AND Linux
#elif defined (_WIN32)
//code for Windows
#else
//unknown platform
#endif