EXTENSIONS

C/C++

Code Runner

配置文件

c_cpp_properties.json

{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "D:/MINGW/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/bin/g++.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4

task.json

{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "D:/MINGW/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/bin/g++.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}

launch.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": [
<pre><code>    {
        "name": "(gdb) Launch",
        "preLaunchTask": "C/C++: g++.exe build active file",//调试前执行的任务,就是之前配置的tasks.json中的label字段
        "type": "cppdbg",//配置类型,只能为cppdbg
        "request": "launch",//请求配置类型,可以为launch(启动)或attach(附加)
        "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",//调试程序的路径名称
        "args": [],//调试传递参数
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": true,//true显示外置的控制台窗口,false显示内置终端
        "MIMode": "gdb",
        "miDebuggerPath": "D:/MINGW/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/bin/gdb.exe",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ]
    }
]</code></pre>
}

常见问题

debugging

这是launch.json文件内解释器的路径错误导致的,在这一行修改地址:

"miDebuggerPath": "D:/MINGW/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/bin/gdb.exe",

配置构建任务时找不到”g+ + .exe build active file”

可能是launch.json文件的preLaunchTask和task.json的lable内容不同导致的。

即launch.json的这一行:

"preLaunchTask": "C/C++: g++.exe build active file"

和task.json的这一行:

"label": "C/C++: g++.exe build active file",

复制task.json文件的label内容到launch.json文件的preLaunchTask内容中即可。

找不到WinMain

shell报错如下:

解决办法(从reddit上找到的):

绷不住了,compile前要先save


参考文章:https://zhuanlan.zhihu.com/p/87864677


0 条评论

发表回复

Avatar placeholder

您的邮箱地址不会被公开。 必填项已用 * 标注