Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/144.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VSCode C++;-#包括<;螺纹>; 我使用VisualStudio代码,C++扩展和G++作为编译器。我正在尝试为线程配置我的环境,但运气不太好。我尝试通过MinGW安装程序安装POSIX线程,但我不确定如何将其正确地包含在我的项目中或包含路径中 #include <string> #include <iostream> #include <thread> void task1(string msg){ cout << "task1 says: " << msg; } int main(){ std::thread t1(task1, "Hello"); t1.join(); }_C++_Multithreading_Visual Studio Code - Fatal编程技术网

VSCode C++;-#包括<;螺纹>; 我使用VisualStudio代码,C++扩展和G++作为编译器。我正在尝试为线程配置我的环境,但运气不太好。我尝试通过MinGW安装程序安装POSIX线程,但我不确定如何将其正确地包含在我的项目中或包含路径中 #include <string> #include <iostream> #include <thread> void task1(string msg){ cout << "task1 says: " << msg; } int main(){ std::thread t1(task1, "Hello"); t1.join(); }

VSCode C++;-#包括<;螺纹>; 我使用VisualStudio代码,C++扩展和G++作为编译器。我正在尝试为线程配置我的环境,但运气不太好。我尝试通过MinGW安装程序安装POSIX线程,但我不确定如何将其正确地包含在我的项目中或包含路径中 #include <string> #include <iostream> #include <thread> void task1(string msg){ cout << "task1 says: " << msg; } int main(){ std::thread t1(task1, "Hello"); t1.join(); },c++,multithreading,visual-studio-code,C++,Multithreading,Visual Studio Code,事实证明,线程实际上不受支持 #include <thread> #包括 但是POSIX线程非常复杂,所以我最终使用了它们: #include <pthread.h> #包括 请包含一个、编译器版本和编译开关。具体来说,您是在C++11模式下使用-std=C++11或更高版本编译的吗?您使用的是哪个版本的gcc?古代版本仍然使用C++03作为默认值。我使用的是gcc 6.3.0,没有指定任何编译开关。使用更多信息进行后期编辑。 #include <pthrea

事实证明,线程实际上不受支持

#include <thread>
#包括
但是POSIX线程非常复杂,所以我最终使用了它们:

#include <pthread.h>
#包括

请包含一个、编译器版本和编译开关。具体来说,您是在C++11模式下使用
-std=C++11
或更高版本编译的吗?您使用的是哪个版本的
gcc
?古代版本仍然使用C++03作为默认值。我使用的是gcc 6.3.0,没有指定任何编译开关。使用更多信息进行后期编辑。
#include <pthread.h>