title: C++ compiling on Windows and Linux: ifdef switch
body: <p>I want to run some c++ code on Linux and Windows.  There are some pieces of code that I want to include only for one operating system and not the other.  Is there a standard <em>#ifdef</em> that once can use?</p>
  
  <p>Something like:</p>
  
  <pre><code>  #ifdef LINUX_KEY_WORD
      ... // linux code goes here.
    #elif WINDOWS_KEY_WORD
      ... // windows code goes here.
    #else 
    #error "OS not supported!"
    #endif
  </code></pre>
  
  <hr>
  
  <p>The question is indeed a duplicate but the answers here are much better, especially the accepted one.</p>