C++ 向量<;int>;无法使用Visual Studio代码中的初始值设定项列表初始化
我在MacOSX上使用VisualStudio代码来构建和运行一个非常基本的矢量程序。这是 代码 这是由Visual Studio代码生成的命令 cd“/Users/XXX/PROJECTS/Algorithms/”和&g++vectors.cpp-o vectors&& “/Users/XXX/PROJECTS/Algorithms/”向量 有人能建议一种在VisualStudioCodeEditor中运行此程序的方法吗C++ 向量<;int>;无法使用Visual Studio代码中的初始值设定项列表初始化,c++,visual-studio-code,vector,C++,Visual Studio Code,Vector,我在MacOSX上使用VisualStudio代码来构建和运行一个非常基本的矢量程序。这是 代码 这是由Visual Studio代码生成的命令 cd“/Users/XXX/PROJECTS/Algorithms/”和&g++vectors.cpp-o vectors&& “/Users/XXX/PROJECTS/Algorithms/”向量 有人能建议一种在VisualStudioCodeEditor中运行此程序的方法吗 谢谢 我仍然无法使用Visual studio代码运行按钮来运行该程序
谢谢 我仍然无法使用Visual studio代码运行按钮来运行该程序,因此我最终使用下面的命令通过命令提示符运行 $g++-std=c++11-o test.cpp 如果有人可以分享他们的task.json,那就很高兴看到了。这是我的
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g++",
"--std=c++11",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "compiler: /usr/bin/g++"
}
]
}它可能没有链接到标准库。试试图中的-stdlib=libc++标志,我可以读到一些被划掉的行。我认为它仍然使用g++而不是任务文件中的clang++。您能确认是否是这样吗?这是命令--cd“/Users/XXX/PROJECTS/Algorithms/”&&g++vectors.cpp-o vectors&&>“/Users/XXX/PROJECTS/Algorithms/”vectorsOT:请注意,您试图隐藏的路径在链接图像的顶部清晰可见。关于这个主题的更多信息,您是如何使用类似于extansion的代码运行程序启动编译过程的?原因确实是您没有使用预期的命令。命令行应该包含
-std=c++11
,而不是。看起来VSCode没有使用您的json文件。。。
{
"version": "2.0.0",
"tasks": [
{
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": [
"$tsc"
],
"group": "build",
"label": "tsc: build - tsconfig.json"
},
{
"type": "typescript",
"tsconfig": "tsconfig.json",
"option": "watch",
"problemMatcher": [
"$tsc-watch"
],
"group": "build",
"label": "tsc: watch - tsconfig.json"
},
{
"type": "cppbuild",
"label": "C/C++: clang build active file",
"command": "/usr/bin/clang",
"args": [
"-g",
"-std=c++11",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: /usr/bin/clang"
}
]
}
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g++",
"--std=c++11",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "compiler: /usr/bin/g++"
}
]