title: unistd.h file not found, clang++ and OS X
body: <p>I'm currently struggling with clang++, and after looking on the web for a long time I decided asking my question. I'm on OS X and using clang++ via Emacs (it's used by flycheck to highlight errors, among other things). I have a very simple file that starts with :</p>
  
  <pre><code>#include &lt;iostream&gt;
  </code></pre>
  
  <p>And the line is underlined in red. When I go check the clang logs, here's what I have :</p>
  
  <pre><code>In file included from ./point.hpp:4:
  In file included from /usr/local/Cellar/llvm/3.6.2/bin/../include/c++/v1/iostream:37:
  /usr/local/Cellar/llvm/3.6.2/bin/../include/c++/v1/__config:23:10: fatal error: 'unistd.h' file not found
  #include &lt;unistd.h&gt;
  </code></pre>
  
  <p>So, the error comes from the <code>iostream</code> include, and in <code>iostream</code> there's a <code>#include &lt;unistd.h&gt;</code> that clang++ doesn't like.</p>
  
  <p>I'll say it immediately, I have Xcode AND the command-line tools installed. So my <code>unistd.h</code> should be there. My code also compiles (via g++), so everything is fine there. It's just clang++ that's lost.</p>
  
  <p>Something I notice is that it's going in my llvm folder (that I installed with homebrew) to fetch <code>iostream</code>, that doesn't seem right. He should be getting the <code>iostream</code> in my system, right ? So <code>/usr/local/include/c++/iostream</code>. Could this be the problem ? If so, how can I tell it to get the right <code>iostream</code> ?</p>
  
  <p>And if it's not the problem, how could I solve my <code>unistd.h</code> problem ?</p>
  
  <p>Thanks in advance !</p>
  
  <p><strong>EDIT</strong> : With the <code>clang++ -stdlib=libc++ image.cpp</code> command, I get this :</p>
  
  <pre><code>clang++ -stdlib=libc++ image.cpp
  In file included from image.cpp:1:
  In file included from ./image.hpp:4:
  In file included from ./figure.hpp:4:
  In file included from ./point.hpp:4:
  In file included from /usr/local/Cellar/llvm/3.6.2/bin/../include/c++/v1/iostream:37:
  /usr/local/Cellar/llvm/3.6.2/bin/../include/c++/v1/__config:23:10: fatal error: 'unistd.h' file not found
  #include &lt;unistd.h&gt;
           ^
  1 error generated.`
  </code></pre>
  
  <p>So, same problem.</p>
  
  <p><strong>EDIT 2</strong> : I noticed <code>which clang++</code> would return <code>/usr/local/bin/clang++</code> , so I tried specifically using the Xcode clang++ and here's the result :</p>
  
  <pre><code>/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -stdlib=libc++ image.cpp
  In file included from image.cpp:1:
  In file included from ./image.hpp:4:
  In file included from ./figure.hpp:4:
  In file included from ./point.hpp:4:
  In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iostream:37:
  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:23:10: fatal error: 'unistd.h' file
    not found
  #include &lt;unistd.h&gt;
           ^
  1 error generated.
  </code></pre>
  
  <p>So same problem on the C++ headers bundled with XCode.</p>