Your basic strategy is deeply flawed.
By using the if in the main function you are selecting which chunk of code to run at RUNTIME.
Thus even if compiling for unix the compiler still has to build the code for windows (which it is failing to do because the header files are not included) and visa versa.
You instead required #if which will be evaluated at compile time and will not attempt to compile irrelevant code.
So in essence you need to understand that if evaluates your define as an expression at runtime whereas #if evaluates the value of the predefined constant at compile time.