簡體   English   中英

用 c++17 調試 VsCode 失敗?

[英]VsCode debugging with c++17 fails?

我遇到了一個問題,我可以在啟用 c++17 標志的情況下構建和運行項目,但實際上無法調試它。 調試器在 vsCode 中啟動,但所有 c++ 17 功能都是紅色波浪線,並且這些行永遠不會正確執行。 我猜這是我的launch.json的問題,但我不知道我錯過了什么......

我運行的是 windows 10,下面是 vsCode 中的相關配置:

任務.json:

{
"tasks": [
    {
        "type": "cppbuild",
        "label": "C/C++: g++.exe build active file",
        "command": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
        "args": [
            "-std=c++17",
            "-g",
            "${fileDirname}\\*.cpp",
            "-o",
            "${fileDirname}\\${fileBasenameNoExtension}.exe"
        ],
        "options": {
            "cwd": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin"
        },
        "problemMatcher": [
            "$gcc"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "detail": "Generated task by Debugger"
    }
],
"version": "2.0.0"

}

發射.json:

    {
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++.exe - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": ["-std=c++17"],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
        }
    ]
}

Welp - 沒有太多答案,但是當我只使用 cl.exe 作為編譯器而不是 gcc 時,問題並沒有發生。 在嘗試讓它工作大約一個小時后,我剛剛停止在這個項目中使用 gcc。

https://code.visualstudio.com/docs/cpp/config-msvc

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM