栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

Mac OS Visual Studio Code(VSCode) C/C++环境配置

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Mac OS Visual Studio Code(VSCode) C/C++环境配置

Mac OS Visual Studio Code(VSCode) C/C++环境配置 安装插件:
    C/C++ 选择Microsoft的Code Runner 运行CodeLLDB 调试
插件配置

对Code Runner选择常用的扩展配置,点击插件 - 设置按钮 - 扩展设置

Code-runner: Clear Previous Output

  • Whether to clear previous output before each run.

    代码运行程序:清除以前的输出

  • 是否在每次运行前清除以前的输出。

    Code-runner: Ignore Selection

  • Whether to ignore selection to always run entire file.

    代码运行者:忽略选择

  • 是否忽略选择以始终运行整个文件。

    Code-runner: Preserve Focus

  • Whether to preserve focus on code editor after code run is triggered.

    代码运行者:保持焦点

  • 触发代码运行后,是否保留对代码编辑器的关注。

    Code- runner: Run In Terminal

  • Whether to run code in Integrated Terminal.

    代码运行程序:运行终端

  • 是否在集成终端中运行代码。

    Code-runner: Save All Files Before Run

  • Whether to save all files before running.

    代码运行程序:运行前保存所有文件

  • 运行前是否保存所有文件。

    Code-runner: Save File Before Run

  • Whether to save the current file before running.

    代码运行程序:运行前保存文件

  • 运行前是否保存当前文件。

    CodeLLDB可以根据需要设置

    Console Mode选择evaluate的话会以弹出终端的方式调试运行,看个人喜好我就不选了。

    工作区配置

    打开一个文件夹创建一个c或cpp文件

    按下Command+shinf+P输入Configure Task,选择配置任务(clang,gcc都可以,如果是c++环境要选带++的),会生成/.vscode/tasks.json文件

    点击左侧调试和运行菜单,点击要自定义运行和调试中的创建launch.json文件,环境选择刚刚安装的LLDB

    launch.json配置 修改program属性,增加preLaunchTask属性,值是tasks.json中的label对应值,可以自行修改

    {
        // 使用 IntelliSense 了解相关属性。 
        // 悬停以查看现有属性的描述。
        // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "type": "lldb",
                "request": "launch",
                "name": "Debug",
                // "program": "${workspaceFolder}/",
                "program": "${fileDirname}/${filebasenameNoExtension}",
                "args": [],
                "cwd": "${workspaceFolder}",
                "preLaunchTask": "cpp"
            }
        ]
    }
    

    tasks.json 可以根据需要修改label的值,不改也可以,总之要与launch.json中的值对应

    {
    	"version": "2.0.0",
    	"tasks": [
    		{
    			"type": "cppbuild",
    			"label": "cpp",
    			"command": "/usr/bin/clang",
    			"args": [
    				"-fdiagnostics-color=always",
    				"-g",
    				"${file}",
    				"-o",
    				"${fileDirname}/${filebasenameNoExtension}"
    			],
    			"options": {
    				"cwd": "${fileDirname}"
    			},
    			"problemMatcher": [
    				"$gcc"
    			],
    			"group": "build",
    			"detail": "编译器: /usr/bin/clang"
    		}
    	]
    }
    
  • 转载请注明:文章转载自 www.mshxw.com
    本文地址:https://www.mshxw.com/it/783971.html
    我们一直用心在做
    关于我们 文章归档 网站地图 联系我们

    版权所有 (c)2021-2022 MSHXW.COM

    ICP备案号:晋ICP备2021003244-6号