Install C/C plug-in
Open the plug-in page, search and enter C/C to search for C/C plug-in.
After installing the plug-in, when using vscode to open the folder containing the cpp file, vscode will add the .vscode subfolder to the directory.
Add c_cpp_properties.json configuration
Run C/Cpp: Edit configurations through the shortcut key ⇧⌘P and add the missing c_cpp_properties.json file. The default added files are as follows:
{ "configurations": [ { "name": "Mac", "includePath": [ "${workspaceFolder}/**" ], "defines": [], "macFrameworkPath": [ "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks" ], "compilerPath": "/usr/bin/clang", "cStandard": "c11", "cppStandard": "c++17", "intelliSenseMode": "clang-x64" } ], "version": 4 }
No adjustments have been made to this part. The files added by default are used.
Add tasks.json configuration file
Select the command to be executed through the shortcut key ⇧⌘P, select the Task: Configure Task command, and select Create tasks.json from templates, Select Others to create an external command. Replace the commnd option according to your own compiler.
{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "label": "cpp", "type": "shell", "command": "g++", "args": [ "-g", "${file}", "-o", "a.out" ], "group": { "kind": "build", "isDefault": true } } ] }
It needs to be said here that we hope to compile and execute the code of the current tab page, so ${file} is used in the args parameter. Another point that needs to be mentioned is that if the output compiled file is not specified, debugging will be affected.
>> g++ -g question.cpp -o a.out
Of course, you can also replace a.out in args with ${file} to maintain correspondence with the file name.
Add the launch.json configuration file
Click Run on the debugging interface, and you will be prompted to add the launch.json configuration file. It defines the relevant attributes of the startup debugging file.
{ // 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。 // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "(lldb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/a.out", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "preLaunchTask": "cpp" } ] }
There are three parameters that need to be explained here:
1. Program parameter. The file name here should correspond to the previous one. If a.out was used earlier, it should also be a. .out.
2. The externalConsole parameter will be displayed when hovering over it. If it is a Linux and other systems, when it is set to false, the printing content will be output within the vscode integration. If true, it will be output to the external terminal. In order to see the output in vscode, set it to false here. Another thing to pay attention to is the parameter externalConsole. If you hover it, it will say. If it is a system such as Linux, when it is set to false, the output will be printed within the vscode integration. content. If true, it will be output to the external terminal. In order to see the output in vscode, set it to false here.
3. preLaunchTask parameter, because each debugging requires pre-compiling the code, here you can specify the compilation task through the preLaunchTask parameter. Here it is designated as the previous task: cpp. That is, the content in the label of the previous task.
Recommended related articles and tutorials: vscode tutorial
The above is the detailed content of How to configure cpp debugging environment in vscode. For more information, please follow other related articles on the PHP Chinese website!

2022年了,该学会用VSCode debug了!下面本篇文章手把手带大家会习VSCode debug,希望对大家有所帮助!

本篇是VSCode配置文章,手把手教大家怎么在VSCode中配置使用 Geant4 和 Root,希望对大家有所帮助!

本篇文章扒拉一下vscode Prettier的选项,总结分享16个让你的代码变漂亮的属性,希望对大家有所帮助!

“工欲善其事,必先利其器!”,vscode作为前端开发的重要工具,其插件能大幅提升战斗力,精心收集12个插件,总有几款你还未曾拥有。

VSCode中如何开发uni-app?下面本篇文章给大家分享一下VSCode中开发uni-app的教程,这可能是最好、最详细的教程了。快来看看!

VScode中怎么开发置C/C++?怎么配置C/C++环境?下面本篇文章给大家分享一下Windows系统下VScode配置C/C++环境图文教程,希望对大家有所帮助!


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),