Нить в C ++ в MacOS X
Я пытаюсь запустить некоторый код, используя потоки в стандартном C ++ (установленном с XCode) в MacOS X Mavericks. Но я получаю некоторые ошибки. Вот минимальный рабочий пример:
#include <thread>
#include <iostream>
void run (int x) {
std::cout<<".";
}
int main (int argc, char const *argv[])
{
std::thread t(run);
}
Ошибка, которую я получаю:
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&);
^
/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.
Я был в состоянии отследить проблему, определяющую мой компилятор_LIBCPP_HAS_NO_VARIADICS
, который определяется из-за
#if !(__has_feature(cxx_variadic_templates))
#define _LIBCPP_HAS_NO_VARIADICS
#endif
Любая помощь будет оценена.
Спасибо!