vscode c++插件与配置

1 本地运行

c/c++ --代码包

code runner --运行包

--C, C++, Java, JS, PHP, Python, Perl, Ruby, Go, Lua, Groovy, PowerShell, CMD, BASH, F#, C#, VBScript, TypeScript, CoffeeScript, Scala,等40多种语言的运行插件

2 mac下c++ debug

C/C++ Clang Command Adapter

CodeLLDB --debug包

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "macFrameworkPath": [],
            "cStandard": "c17",
            "cppStandard": "c++17",
            "compilerPath": "/usr/bin/clang++",
            "intelliSenseMode": "macos-clang-arm64"
        }
    ],
    "version": 4
}

task.json

image

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "echo",
            "type": "shell",
            "command": "echo Hello"
        },
        {
            "type": "cppbuild",
            "label": "C/C++: clang++",
            "command": "/usr/bin/clang++",
            "args": [
                "-g",
                "${workspaceFolder}/*.cpp",  //  将${file} 修改为自定义目录
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"  // 必须和 launch.json 中的 programe 选项一致
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "编译器: /usr/bin/clang++"
        }
    ]
}

launch.json

image

{
	"version": "0.2.0",
	"configurations": [
		{
			"name": "(lldb) 启动",
			"type": "lldb",		//修改 ccpdbg 为lldb 或者 gdb (根据自己的需求)
			"request": "launch",
			"program": "${fileDirname}/${fileBasenameNoExtension}",    //必须和 task.json 中的 args 输出路径一致
			"args": [],
			"cwd": "${workspaceFolder}", 	
			"osx": {
				"MIMode": "lldb"
			},
			"preLaunchTask": "C/C++: clang++"
		}
	]
}

"MIMode": "lldb",改为"osx": { "MIMode": "lldb" },

参考自 https://code.visualstudio.com/docs/cpp/launch-json-reference
image

posted @ 2021-06-09 18:37  CTHON  阅读(810)  评论(0编辑  收藏  举报