title: Thread in C++ in MacOS X
body: <p>I'm trying to run some code using threads in standard C++ (installed with XCode) in MacOS X Mavericks. But I'm getting some errors. Here's a minimal working example:</p>
  
  <pre><code>#include &lt;thread&gt;
  #include &lt;iostream&gt;
  
  void run (int x) {
      std::cout&lt;&lt;".";
  }
  
  int main (int argc, char const *argv[])
  {
      std::thread t(run);
  }
  </code></pre>
  
  <p>The error I'm getting:</p>
  
  <pre><code>minimal.cpp:10:17: error: no matching constructor for initialization of 'std::thread'
  std::thread t(run,0);
              ^ ~~~~~
  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/thread:372:9: note: candidate constructor template not viable: requires single argument '__f', but 2 arguments
    were provided
  thread::thread(_Fp __f)
      ^
  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/thread:261:5: note: candidate constructor not viable: requires 1 argument, but 2 were provided
  thread(const thread&amp;);
  ^
  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/thread:268:5: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
  thread() _NOEXCEPT : __t_(0) {}
  ^
  1 error generated.
  </code></pre>
  
  <p>I've been able to track the problem to my compiler defining <code>_LIBCPP_HAS_NO_VARIADICS</code>, which is defined because of </p>
  
  <pre><code>#if !(__has_feature(cxx_variadic_templates))
  #define _LIBCPP_HAS_NO_VARIADICS
  #endif
  </code></pre>
  
  <p>Any help would be appreciated. </p>
  
  <p>Thank you!</p>