Normally multi-platform APIs develop code specific to each platform and do not have runtime. The code is only specified at compile time for a target platform.
For this, they usually define macros to check which OS is.
This is what Qt and wxWidgets .
In the header of your API you define:
#ifdef defined(__WIN32__) || defined(__NT__)
# define MEU_API_WINDOWS
# endif
#if defined(__linux__) || defined(__linux)
# define MEU_API_LINUX
#endif
#if defined(__APPLE__)
# defined MEU_API_OSX
#endif
void foo();
Then you can define your code as follows:
void foo()
{
#if defined(MEU_API_WINDOWS)
// código para windows
#elif defined(MEU_API_LINUX)
// código para linux
#elif defined(MEU_API_OSX)
// código para OS X.
#endif
// etc
}
And with that you would need only one header and the foo () function would work on all the platforms you have planned.
Alternatively, you can define foo () in different .c files for each platform (it gets more organized) by doing the OS checks on each file.
For example, for foo_linux.c
:
#ifdef MEU_API_LINUX
#include <lib_do_linux.h>
void foo()
{
// TODO
}
#endif
And no foo_windows.c
:
#ifdef MEU_API_WINDOWS
#include <lib_do_windows.h>
void foo()
{
// TODO
}
#endif
I recommend that you take a look at Qt and wxWidgets implementations as they both deal well with this.