MacOS-配置VsCode的C/C++运行文件

    最近,迷上了VsCode这款编辑器,被它的颜值完全吸引到了,由于最近某杯的算法比赛开始了,所以我最近想用VsCode去编辑运行C/C++,苦于找了好多的方法,最后终于实现了。现在就来记录一下整个配置的过程:

    1.首先需要下载VsCode(滑稽😄),并下载所需要的插件。



    2.在电脑上新建一个文件夹(作为C/C++的运行文件夹,我就建在Desktop上了)如下图,很简单。

3.打开VsCode,打开新建的C/C++文件夹。依然很简单。(Mac快捷键command+O,打开文件)

4.开始新建一个.cpp文件。(新建快捷键 command+N)


5.配置3个文件。

(1)c_cpp_properties.json

{

    "configurations": [

        {

            "name": "Mac",

            "includePath": [

                "${workspaceFolder}/**"

            ],

            "defines": [],

            "macFrameworkPath": [

                "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks"

            ],

            "compilerPath": "/usr/bin/clang",

            "cStandard": "c11",

            "cppStandard": "c++17",

            "intelliSenseMode": "clang-x64"

        }

    ],

    "version": 4

}


(2)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": [

        {

            "name": "c/c++ Launch",

            "type": "cppdbg",

            "request": "launch",

            "program": "${workspaceFolder}/a.out",

            "args": [],

            "stopAtEntry": false,

            "cwd": "${workspaceFolder}",

            "environment": [],

            "externalConsole": true,

            "MIMode": "lldb",

            "preLaunchTask":"c++"

        }

    ]

}


(3)tasks.json

{

    // See https://go.microsoft.com/fwlink/?LinkId=733558

    // for the documentation about the tasks.json format

    "version": "2.0.0",

    "tasks": [

        {

            "label": "c++",

            "command": "clang++",

            "type": "shell",

            "args": [

                "${file}",

                "-std=c++11",

                "-g"

            ],

            "presentation": {

                "echo": true,

                "reveal": "always",

                "focus": false,

                "panel": "shared"

            },

            "group": {

                "kind": "build",

                "isDefault": true

            }

        }

    ]

}



然后就可以运行已经写好的jianshu.cpp文件了。


©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容