小编Zic*_*ang的帖子

VSCode - 有红色下划线但程序构建并运行正确,并且调试错误

我已将 vscode 配置为在 Linux 上使用 c++。最近想写一个新的cpp程序,我按照MS VScode教程进行操作,但是当我将代码复制到VScode时,出现红色下划线并提示如下: 错误

但是,我可以构建它,甚至可以正确运行它而不会出现错误:运行构建任务 在终端中运行它

当我调试它时,就会出现错误。

{
    "resource": "/home/aqachun/Documents/Projects/cpp/vscodeTest/helloworld.cpp",
    "owner": "C/C++",
    "severity": 8,
    "message": "no instance of constructor \"std::vector<_Tp, _Alloc>::vector [with _Tp=std::string, _Alloc=std::allocator<std::string>]\" matches the argument list -- argument types are: (const char [6], const char [4], const char [6], const char [5], const char [8], const char [23])",
    "startLineNumber": 9,
    "startColumn": 24,
    "endLineNumber": 9,
    "endColumn": 24
}
Run Code Online (Sandbox Code Playgroud)

这是我的 c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Linux",
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "includePath": [
                "${default}",
                "/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../include/c++/9.2.0", …
Run Code Online (Sandbox Code Playgroud)

c++ visual-studio-code

5
推荐指数
1
解决办法
7304
查看次数

标签 统计

c++ ×1

visual-studio-code ×1