伸手黨進(jìn):具體步驟主要是這篇:Hudiscount-Vscode配置C/C++環(huán)境
MinGW-W64 x86_64-win32-seh高速下載
去目錄1的第二個(gè)鏈接,并將壓縮包解壓至一個(gè)你覺(jué)得合適的路徑,并配置環(huán)境變量,具體配置步驟見(jiàn)目錄1的第一個(gè)鏈接;
建議先新建一個(gè)文件夾,將C/C++的環(huán)境(包括.json文件)全部保存在這個(gè)文件夾里,配置其他語(yǔ)言的環(huán)境時(shí)也是如此,這樣不會(huì)亂。
同目錄1的第一個(gè)鏈接;
到了第(7)步時(shí),小蟲(chóng)子那段,我直接跳過(guò)(主要是也沒(méi)看懂,試了下也沒(méi)啥用),因?yàn)橹暗囊恍¬Scode配置經(jīng)驗(yàn)告訴我最重要的是.json文件的內(nèi)容不要錯(cuò)就可以,
參考我的三個(gè).json:
launch.json:
{// 使用 IntelliSense 了解相關(guān)屬性。
// 懸停以查看現(xiàn)有屬性的描述。
// 欲了解更多信息,請(qǐng)?jiān)L問(wèn): https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{"name": "g++.exe - 生成和調(diào)試活動(dòng)文件",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "D:/VScode_C/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/bin",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "D:/VScode_C/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/bin/gdb.exe",
"setupCommands": [
{"description": "為 gdb 啟用整齊打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe 生成活動(dòng)文件"
}
]
}
tasks.json:
{"version": "2.0.0",
"tasks": [
{ "type": "cppbuild",
"label": "C/C++: g++.exe 生成活動(dòng)文件",
"command": "D:\\VScode_C\\x86_64-8.1.0-release-win32-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": { "cwd": "D:\\VScode_C\\x86_64-8.1.0-release-win32-seh-rt_v6-rev0\\mingw64\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": { "kind": "build",
"isDefault": true
},
"detail": "編譯器: D:\\VScode_C\\x86_64-8.1.0-release-win32-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe"
}
]
}
c_cpp _properties.json:
{"configurations": [
{"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "D:/VScode_C/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/bin/g++.exe",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "windows-gcc-x64"
}
],
"version": 4
}
實(shí)際上修改完Configurations后,
c_cpp _properties.json會(huì)自動(dòng)修改。
C版本:
#includeint main()
{printf("Hello,world!\n");
return 0;
}
C++版本:
#includeusing namespace std;
int main(){cout<<"Hello,VScode!"<
神奇的是C的輸出直接跳轉(zhuǎn)至VScode輸出,更方便,可能是之前裝過(guò)coderunner的事;
而C++的輸出依舊是.exe黑框框彈窗:
你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級(jí)服務(wù)器適合批量采購(gòu),新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧