title: Determine OS during runtime
body: <p>Neither ISO C nor POSIX offer functionality to determine the underlying OS during runtime. From a theoretical point of view, it doesn't matter since C offers wrappers for the most common system calls, and from a nit-picking point of view, there doesn't even have to <em>be</em> an underlying OS.</p>
  
  <p>However, in many real-world scenarios, it has proven helpful to know more about the host environment than C is willing to share, e.g. in order to find out where to store config files or how to call <code>select()</code>, so:</p>
  
  <p>Is there an idiomatic way for an application written in C to determine the underlying OS during runtime?</p>
  
  <p>At least, can I easily decide between Linux, Windows, BSD and MacOS?</p>
  
  <p>My current guess is to check for the existence of certain files/directories, such as <code>C:\</code> or <code>/</code>, but this approach seems unreliable. Maybe querying a series of such sources may help to establish the notion of "OS fingerprints", thus increasing reliability. Anyway, I'm looking forward to your suggestions.</p>