Visual Studio Code 在编译“_zst28__ throw_bad_array_new_lengthv”时无法识别 std 库
所以基本上我遵循的是使用 Visual Studio Code 设置 C++ 的官方文档。所以我按照每一步操作并复制了他们的代码:
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
vector<string> msg{"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};
for (const string &word : msg)
{
cout << word << " ";
}
cout << endl;
}
编辑 当我编译代码时,会正确生成 .exe 文件。但是,当我尝试运行编译程序 我弹出以下错误。。当我尝试从 VSCode 终端运行它时,我没有收到错误 "_zst28__ throw_bad_array_new_lengthv", 它只是得到不执行任何操作就执行 这是我的 task.json 配置。我不确定我在设置时哪里出错了。代码可以编译,但无法运行。
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe compilar archivo activo",
"command": "C:\\msys64\\mingw64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compilador: C:\\msys64\\mingw64\\bin\\g++.exe"
}
]
}
So basically I was following the official documentation of setting up C++ with Visual Studio Code. So I followed every step and copied their code:
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
vector<string> msg{"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};
for (const string &word : msg)
{
cout << word << " ";
}
cout << endl;
}
EDIT When I compile the code an .exe file is generated correctly. However, when I try to run the compile programme I get the following mistake as popup.. When I try to run it from my VSCode terminal I don't get that mistake "_zst28__throw_bad_array_new_lengthv", it just gets executed without doing anything
This is my task.json configuration. I am not sure where I made a mistake while setting up. The code compiles, but it does not run.
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe compilar archivo activo",
"command": "C:\\msys64\\mingw64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compilador: C:\\msys64\\mingw64\\bin\\g++.exe"
}
]
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论