Standard C doesn't care about which OS you're on, so there is no standard way to find out. Not that this is much of a problem, since each OS has a different executable format (not to mention many different processor types), you can't just compile a bit of code and then expect it to execute on any machine.
When you compile the code, you typically have
Unfortunately, there is no standard naming convention for those defines.
/* code specific to DOS here */
/* code specific to Win32 here */
/* code specific to Linux here */
#error Need another OS
An alternative is to put all the non-portable code into
In either case, it's a good idea to minimise the amount of code in such places.