MacOS-配置VsCode的C/C++運(yùn)行文件

? ? 最近,迷上了VsCode這款編輯器,被它的顏值完全吸引到了,由于最近某杯的算法比賽開始了,所以我最近想用VsCode去編輯運(yùn)行C/C++,苦于找了好多的方法,最后終于實(shí)現(xiàn)了。現(xiàn)在就來記錄一下整個配置的過程:

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



? ? 2.在電腦上新建一個文件夾(作為C/C++的運(yùn)行文件夾,我就建在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

? ? ? ? ? ? }

? ? ? ? }

? ? ]

}



然后就可以運(yùn)行已經(jīng)寫好的jianshu.cpp文件了。


?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容