是的标题几乎总结了我的问题。我甚至可以查看定义线程的标题。
建筑不是问题!至少使用此代码段。只是错误标记是我的问题!
错误: "没有名为' thread'在命名空间' std'"
编译任务: "命令":" g ++ -Wall -g -std = c ++ 17 -pthread main.cpp -o CANToolLinux"
铛:
clang version 4.0.1-6(tags / RELEASE_401 / final)目标:x86_64-pc-linux-gnu线程模型:posix
Stackoverflow希望我输入更多详细信息,但我真的不知道这里需要什么细节。对VS Code来说很新。另一个与这个问题毫无关系的愚蠢的事情我想是经过一段时间后我的c_cpp_properties.json会忘记我输入的所有包含路径。但是昨天发生这种情况。今天文件看起来很好。
#include <vector>
#include <thread>
#include <iostream>
void work()
{
//Do something
}
int main()
{
std::thread t(work);
t.join();
return 0;
}
我的c_cpp_properties.json:
"configurations": [
{
"name": "Linux",
"includePath": [
"/usr/include/c++/7",
"/usr/include/x86_64-linux-gnu/c++/7",
"/usr/include/c++/7/backward",
"/usr/lib/gcc/x86_64-linux-gnu/7/include",
"/usr/local/include",
"/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed",
"/usr/include/x86_64-linux-gnu",
"/usr/include",
"/usr/src/linux-headers-4.13.0-37"
],
"defines": [],
"browse": {
"path": [
"/usr/include/c++/7",
"/usr/include/x86_64-linux-gnu/c++/7",
"/usr/include/c++/7/backward",
"/usr/lib/gcc/x86_64-linux-gnu/7/include",
"/usr/local/include",
"/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed",
"/usr/include/x86_64-linux-gnu",
"/usr/include",
"/usr/src/linux-headers-4.13.0-37"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"intelliSenseMode": "clang-x64"
}
],
"version": 3
VS代码中的