编译运行通过,但是弹出无法打开:267272320315313343267250.cpp,找不到文件

发布于 2022-09-07 04:29:51 字数 7174 浏览 8 评论 0

VSCode
源代码是一个很简答的cpp文件,只涉及标准库导入。
编译和运行都通过了,只是有这样一个错误警告,如下图。
267272320315313343267250.cpp不是我的文件,那么这个是如何来的?为什么要打开这个文件?编译运行仍然通过了?
问题很菜鸟,不知道去查找哪方面的问题,跪谢

图片描述

红框放大如下:

clipboard.png

clipboard.png

launch.json如下:


// https://github.com/Microsoft/vscode-cpptools/blob/master/launch.md
{
    "version": "0.2.0",
    "configurations": [
        
        {
            "name": "(gdb) Launch", // 配置名称,将会在启动配置的下拉菜单中显示
            "type": "cppdbg", // 配置类型,这里只能为cppdbg
            "request": "launch", // 请求配置类型,可以为launch(启动)或attach(附加)
            "program": "${fileDirname}/${fileBasenameNoExtension}.exe", // 将要进行调试的程序的路径
            "args": [], // 程序调试时传递给程序的命令行参数,一般设为空即可
            "stopAtEntry": false, // 设为true时程序将暂停在程序入口处,我一般设置为true
            "cwd": "${workspaceFolder}", // 调试程序时的工作目录
            "environment": [], // (环境变量?)
            "externalConsole": true, // 调试时是否显示控制台窗口,一般设置为true显示控制台
            "internalConsoleOptions": "neverOpen", // 如果不设为neverOpen,调试时会跳到“调试控制台”选项卡,你应该不需要对gdb手动输命令吧?
            "MIMode": "gdb", // 指定连接的调试器,可以为gdb或lldb。但目前lldb在windows下没有预编译好的版本。
            "miDebuggerPath": "gdb.exe", // 调试器路径。
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": false
                }
            ],
            "preLaunchTask": "Compile" // 调试会话开始前执行的任务,一般为编译程序。与tasks.json的label相对应
        }
    ]
}

task.json文件如下:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Compile", 
            "command": "g++",
            "args": [
                "${file}",
                "-o", 
                "${fileDirname}/${fileBasenameNoExtension}.exe",
                "-g",
                "-Wall",
                "-static-libgcc",
                "-std=c++11"
            ],
            "type": "shell",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "echo": true,
                "reveal": "always", 
                "focus": false, 
                "panel": "shared"
            },
            "problemMatcher":"$gcc"
        }
    ]
}

setting文件如下:

    "files.defaultLanguage": "cpp", 

    "code-runner.runInTerminal": true, 
    "code-runner.executorMap": {
        "c": "cd $dir && clang $fileName -o $fileNameWithoutExt.exe -Wall -g -Og -static-libgcc -fcolor-diagnostics --target=x86_64-w64-mingw -std=c11 && $dir$fileNameWithoutExt",
        "cpp": "cd $dir && clang++ $fileName -o $fileNameWithoutExt.exe -Wall -g -Og -static-libgcc -fcolor-diagnostics --target=x86_64-w64-mingw -std=c++17 && $dir$fileNameWithoutExt"
    }, 
    "code-runner.preserveFocus": true, 
    "code-runner.clearPreviousOutput": false, 

    "C_Cpp.clang_format_sortIncludes": true, 
    "C_Cpp.intelliSenseEngine": "Default", 
    "C_Cpp.errorSquiggles": "Disabled", 
    "editor.formatOnType": true, 
    "editor.snippetSuggestions": "top", 

    "clang.cflags": [ 
        "--target=x86_64-w64-mingw",
        "-std=c11",
        "-Wall"
    ],
    "clang.cxxflags": [
        "--target=x86_64-w64-mingw",
        "-std=c++17",
        "-Wall"
    ],
    "clang.completion.enable":false ,

c_cpp_properties.json如下:

{
    "configurations": [
        {
            "name": "Win32",
            "intelliSenseMode": "clang-x64",
            "includePath": [
                "${workspaceFolder}",
                "C:/Program Files/LLVM/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++",
                "C:/Program Files/LLVM/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/x86_64-w64-mingw32",
                "C:/Program Files/LLVM/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/backward",
                "C:/Program Files/LLVM/lib/gcc/x86_64-w64-mingw32/7.2.0/include",
                "C:/Program Files/LLVM/include",
                "C:/Program Files/LLVM/x86_64-w64-mingw32/include",
                "C:/Program Files/LLVM/lib/gcc/x86_64-w64-mingw32/7.2.0/include-fixed"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "__GNUC__=7",
                "__cdecl=__attribute__((__cdecl__))"
            ],
            "browse": {
                "path": [
                    "${workspaceFolder}",
                    "C:/Program Files/LLVM/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++",
                    "C:/Program Files/LLVM/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/x86_64-w64-mingw32",
                    "C:/Program Files/LLVM/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/backward",
                    "C:/Program Files/LLVM/lib/gcc/x86_64-w64-mingw32/7.2.0/include",
                    "C:/Program Files/LLVM/include",
                    "C:/Program Files/LLVM/x86_64-w64-mingw32/include",
                    "C:/Program Files/LLVM/lib/gcc/x86_64-w64-mingw32/7.2.0/include-fixed"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "cStandard": "c11",
            "cppStandard": "c++11"
        }
    ],
    "version": 3
}

源代码:

#include <algorithm>
#include <iostream>
#include <list>
#include <string>
#include <vector>

void elim_dups(std::vector<std::string> &words)
{
    std::sort(words.begin(), words.end());
    std::vector<std::string>::iterator end_of_unique = std::unique(words.begin(), words.end());
    words.erase(end_of_unique, words.end());
}

bool is_shorter(const std::string &sa, const std::string &sb)
{
    return sa.size() < sb.size();
}

void elim_dups_stable(std::vector<std::string> &words)
{
    elim_dups(words);
    std::stable_sort(words.begin(), words.end(), is_shorter);
}

//使用lambda表达式构造比较函数
void elim_dups_stable_lambda(std::vector<std::string> &words)
{
    elim_dups(words);
    std::stable_sort(words.begin(), words.end(),
                        //这样的lambda表达式可以省略 ->bool,编译器会自动推断返回类型
                     [](const std::string &sa, const std::string &sb) -> bool { return sa.size() < sb.size(); });
    
}
int main()
{
    std::vector<int> intab{1, 2, 3, 4, 5, 6};
    std::vector<std::string> str{"ab", "ac", "abc", "cb", "ca", "cba", "cbb", "ca", "cbc", "cc"};
    elim_dups(str);
    for (auto var : str)
    {
        std::cout << var << " ";
    }

    std::cout << std::endl;
    elim_dups_stable_lambda(str);
    for (auto var : str)
    {
        std::cout << var << " ";
    }
    return 0;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文