日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

VS Code配置C/C++

發布時間:2024/7/19 c/c++ 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 VS Code配置C/C++ 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

VS Code 配置C/C++

? 準備工作
Mingw-w64下載,在vscode中,點擊幫助?文檔,進入如下界面。

在左側選擇C++?Mingw-w64 onWindows,進入如下界面。可以參考文檔進行配置。

點擊文檔中的mingw-w64鏈接進入如下界面。

點擊黃色區域鏈接進入到里面,再點擊下圖中的文字,進入到下載界面,下載即可。

將其自定義安裝(我的安裝在了mingw文件夾下),記住配置其路徑,D:\mingw\mingw64\bin。

? 擴展vscode插件,如下。

? .json文件配置,C/C++需要三個配置文件。
? c_cpp_properties.json
? tasks.json
? launch.json
可以參看文檔的配置,也可以根據自己的情況設置。

對于配置文檔的一些介紹:
對于launch.json文件,“configurations”: [],中括號里是書寫配置信息的,每一個配置信息,由一個{}包括, {}由逗號分隔,每個配置都會在如下圖的位置顯示出來,便于調用:

對于每一個{}包含的配置的具體項介紹如下:

{"name": "C++ Run(minGW64)","type": "cppdbg","request": "launch","program": "${workspaceFolder}/${fileBasenameNoExtension}.exe","MIMode": "gdb","miDebuggerPath": "D:/mingw/mingw64/bin/gdb.exe","args": [],"stopAtEntry": false,"environment": [],"cwd": "${workspaceRoot}","externalConsole": false,"preLaunchTask": "C++ Run","setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": false}]},

Name的值可以人為設定,會在上述位置顯示,便于區分,而"preLaunchTask": "C++ Run"這個的值,則對于tasks.json中的一個任務,其值必須和label的值對應,如下:

{"label": "C++ Run","type": "shell","command": "g++","args": ["-o","${fileBasenameNoExtension}","${file}"],"group": {"kind": "build","isDefault": true}

可以設置多對上述的對應關系,用于不同語言的編譯調試。

下面是我的這幾個文件的具體配置:
? c_cpp_properties.json

{"configurations": [{"name":"C++/Win32","includePath": ["${workspaceRoot}","D:/mingw/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++","D:/mingw/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32","D:/mingw/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward","D:/mingw/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include","D:/mingw/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/tr1","D:/mingw/mingw64/include"],"defines": ["_DEBUG","UNICODE","__GNUC__=6","__cdecl=__attribute__((__cdecl__))"],"intelliSenseMode": "clang-x64","browse":{"path": ["${workspaceRoot}","D:/mingw/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++","D:/mingw/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32","D:/mingw/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward","D:/mingw/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include","D:/mingw/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/tr1","D:/mingw/mingw64/include"]},"compilerPath": "D:/mingw/mingw64/bin/gcc.exe","cStandard": "c11","cppStandard": "c++17"}],"version": 4 }

? launch.json

{// 使用 IntelliSense 了解相關屬性。 // 懸停以查看現有屬性的描述。// 欲了解更多信息,請訪問: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [{"type": "java","name": "CodeLens (Launch) - DigitalImage","request": "launch","mainClass": "app.DigitalImage","projectName": "main"},{"name": "C++ Run(minGW64)","type": "cppdbg","request": "launch","program": "${workspaceFolder}/${fileBasenameNoExtension}.exe","MIMode": "gdb","miDebuggerPath": "D:/mingw/mingw64/bin/gdb.exe","args": [],"stopAtEntry": false,"environment": [],"cwd": "${workspaceRoot}","externalConsole": false,"preLaunchTask": "C++ Run","setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": false}]},{"name": "C++ Debug(minGW64)","type": "cppdbg","request": "launch","program": "${workspaceFolder}/${fileBasenameNoExtension}.exe","MIMode": "gdb","miDebuggerPath": "D:/mingw/mingw64/bin/gdb.exe","args": [],"stopAtEntry": false,"environment": [],"cwd": "${workspaceRoot}","externalConsole": true,"preLaunchTask": "C++ Debug","setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": false}]},{"name": "C Run(minGW64)","type": "cppdbg","request": "launch","program": "${workspaceFolder}/${fileBasenameNoExtension}.exe","MIMode": "gdb","miDebuggerPath": "D:/mingw/mingw64/bin/gdb.exe","args": [],"stopAtEntry": false,"environment": [],"cwd": "${workspaceRoot}","externalConsole": true,"preLaunchTask": "C Run","setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": false}]},{"name": "C Debug(minGW64)","type": "cppdbg","request": "launch","program": "${workspaceFolder}/${fileBasenameNoExtension}.exe","MIMode": "gdb","miDebuggerPath": "D:/mingw/mingw64/bin/gdb.exe","args": [],"stopAtEntry": false,"environment": [],"cwd": "${workspaceRoot}","externalConsole": true,"preLaunchTask": "C Debug","setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": false}]}] }

? tasks.json

{"version": "2.0.0","tasks": [//C++ Run Tasks{"label": "C++ Run","type": "shell","command": "g++","args": ["-o","${fileBasenameNoExtension}","${file}"],"group": {"kind": "build","isDefault": true}},//C++ Debug Tasks{"label": "C++ Debug","type": "shell","command": "g++","args": ["-g","-o", "${fileBasenameNoExtension}","${file}"],"group": {"kind": "build","isDefault": true}},//C Run Tasks{"label": "C Run","type": "shell","command": "gcc","args": ["-o","${fileBasenameNoExtension}","${file}"],"group": {"kind": "build","isDefault": true}},//C Debug Tasks{"label": "C Debug","type": "shell","command": "gcc","args": ["-g","-o", "${fileBasenameNoExtension}","${file}"],"group": {"kind": "build","isDefault": true}}] }

參考鏈接:
https://www.cnblogs.com/TAMING/p/8560253.html
https://www.cnblogs.com/zhuzhenwei918/p/9057289.html
https://www.cnblogs.com/wanghao-boke/p/12076302.html
https://www.cnblogs.com/jpfss/p/10333911.html

總結

以上是生活随笔為你收集整理的VS Code配置C/C++的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。