I always try to keep the platform specifics out of the main code by doing it this way
platform.h:
#if BUILD_PLATFORM == WINDOWS_BUILD
#include "windows_platform.h"
#elif BUILD_PLATFORM == LINUX_BUILD
#include "linux_platform.h"
#else
#error UNSUPPORTED PLATFORM
#endif
someclass.c:
void SomeClass::SomeFunction()
{
system_related_type t;
// Other code
platform_SystemCall(&t);
// Other code
}
Now in windows_platform.h
and linux_platform.h
you typedef system_related_type
to the native type, and either #define platform_SystemCall
as the native call, or create a small wrapper function, if the argument set from one platform to the other is too different.
If the system APIs for a particular task are wildly different between platforms, you may need to create your own version API that splits the difference. But for the most part, there are fairly direct mappings between the various APIs on Windows and Linux.
Rather than relying on some particular compiler #define to select platform, I #define BUILD_PLATFORM in the project file or makefile, since those have to be unique by platform anyway.