{"id":899,"date":"2022-02-19T17:18:30","date_gmt":"2022-02-19T17:18:30","guid":{"rendered":"https:\/\/codevoweb.com\/?p=899"},"modified":"2022-08-27T15:17:50","modified_gmt":"2022-08-27T15:17:50","slug":"set-up-vs-code-to-write-and-debug-cpp-programs","status":"publish","type":"post","link":"https:\/\/codevoweb.com\/set-up-vs-code-to-write-and-debug-cpp-programs\/","title":{"rendered":"How to Set up VS Code to write and debug C\/C++ Programs"},"content":{"rendered":"\n<p><a href=\"https:\/\/code.visualstudio.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Visual Studio Code<\/a> is an open-source editor developed by Microsoft and anyone with programming skills can customize it to meet their need.<\/p>\n\n\n\n<p>VS Code has grown to become so popular that it&#8217;s now the default text editor for beginner developers.<\/p>\n\n\n\n<p>VS Code is a flexible and lightweight IDE or text editor meaning it doesn&#8217;t eat up your memory and CPU like other IDEs that are robust. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"450\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/How-to-setup-vs-code-to-program-cpp-applications.webp\" alt=\"How to setup vs code to program cpp applications\" class=\"wp-image-973\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/How-to-setup-vs-code-to-program-cpp-applications.webp 800w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/How-to-setup-vs-code-to-program-cpp-applications-300x169.webp 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/How-to-setup-vs-code-to-program-cpp-applications-768x432.webp 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/How-to-setup-vs-code-to-program-cpp-applications-100x56.webp 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/How-to-setup-vs-code-to-program-cpp-applications-700x394.webp 700w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/How-to-setup-vs-code-to-program-cpp-applications-600x338.webp 600w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>VS Code has a lot of advantages that make it stand out from its competitors like Sublime Text, Atom, Vim, and Emacs.<\/p>\n\n\n\n<p>Another great thing about VS Code is it has a lot of helpful tools and plugins that you can install from the Extension Marketplace to further make VS Code more powerful.<\/p>\n\n\n<style>.kb-table-of-content-nav.kb-table-of-content-id_ad002b-be .kb-table-of-content-wrap{padding-top:10px;padding-right:10px;padding-bottom:10px;padding-left:10px;border-color:#abb8c3;border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;}.kb-table-of-content-nav.kb-table-of-content-id_ad002b-be .kb-table-of-contents-title-wrap{padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.kb-table-of-content-nav.kb-table-of-content-id_ad002b-be .kb-table-of-contents-title-wrap{color:#ffffff;}.kb-table-of-content-nav.kb-table-of-content-id_ad002b-be .kb-table-of-contents-title{color:#ffffff;font-weight:regular;font-style:normal;}.kb-table-of-content-nav.kb-table-of-content-id_ad002b-be .kb-table-of-content-wrap .kb-table-of-content-list{color:#ffffff;font-weight:regular;font-style:normal;margin-top:10px;margin-right:0px;margin-bottom:0px;margin-left:-15px;}<\/style>\n\n\n<p>You can also read:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"\/top-21-vs-code-shortcuts-for-every-programmer\">Top 21 VS Code Shortcuts Every Programmer Should Master<\/a><\/li><li><a href=\"\/25-vs-code-productivity-tips-and-speed-hacks\">25 VS Code Productivity Tips and Speed Hacks<\/a><\/li><\/ul>\n\n\n\n<span id=\"ezoic-pub-video-placeholder-25\"><\/span>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"c-dev-tools\">C++ Dev Tools<\/h2>\n\n\n\n<p>As a C++ developer, I recommend you choose one text editor like VS Code then get your hands dirty by playing with it, and also learn the various shortcuts VS Code provides to improve your productivity.<\/p>\n\n\n\n<p>Since C++ is a compiled language, we are going to need a compiler to convert the human-readable code we write in VS Code into a binary executable file.<\/p>\n\n\n\n<p>The computer or CPU doesn&#8217;t understand the human-readable code we write in the editor so we need a compiler that can compile our code to machine language for the CPU to understand.<\/p>\n\n\n\n<p>Instead of installing a single compiler, we are going to install or set up three different compilers (<strong>Mingw<\/strong>, <strong>Msvc<\/strong> &amp; <strong>Clang LLVM<\/strong>) so that we can test our C++ code to make sure it can run with different compilers.<\/p>\n\n\n\n<p>In this article, we are going to set up VS Code workspace for C++ programming, install three different compilers, set up debugger settings and install helpful extensions and AI tools to ease our C++ development process.<\/p>\n\n\n\n<p>Here are the steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Installing three different Compilers<\/li><li>VS Code Workspace Set up<\/li><li>Install essential extensions and AI tools<\/li><li>Setup debugger settings<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-the-different-c-compilers\">Installing the different C++ Compilers<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"the-c-compilers-for-windows-computer\">The C++ Compilers for Windows computer<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>Mingw<\/li><li>Msvc<\/li><li>Clang llvm<\/li><\/ul>\n\n\n\n<p>Before we start installing the various compilers, we need to check the features that are supported by the different compilers.<\/p>\n\n\n\n<p>Search for C++ compiler support in Google and select the first link or visit <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/compiler_support\" target=\"_blank\" rel=\"noreferrer noopener\">C++ compiler support<\/a>.<\/p>\n\n\n\n<p>At the time of writing this article, C++20 is the latest stable version of C++ so scroll down to C++20 core language features.<\/p>\n\n\n\n<p>Now you can see the various features that are supported by each compiler. <\/p>\n\n\n\n<p>When am writing C++ programs my primary compiler is <a href=\"https:\/\/gcc.gnu.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">GCC<\/a> but I also test my program with the other compilers to increase my chances of my program running well with other compilers.<\/p>\n\n\n\n<p>If you happen to use a particular feature that doesn&#8217;t work with your compiler then this is a good place to come to see if your compiler supports that feature.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"694\" height=\"1024\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/C-compilers-support-694x1024.png\" alt=\"C++ compilers support\" class=\"wp-image-907\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/C-compilers-support-694x1024.png 694w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/C-compilers-support-203x300.png 203w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/C-compilers-support-768x1134.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/C-compilers-support-1040x1536.png 1040w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/C-compilers-support-68x100.png 68w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/C-compilers-support-305x450.png 305w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/C-compilers-support-813x1200.png 813w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/C-compilers-support-600x886.png 600w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/C-compilers-support.png 1337w\" sizes=\"auto, (max-width: 694px) 100vw, 694px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-to-install-mingw-compiler\">How to install Mingw compiler<\/h3>\n\n\n\n<p>Am going to show you how you can install both GCC and Clang compilers together.<\/p>\n\n\n\n<p>Navigate to this website <a href=\"https:\/\/winlibs.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Winlibs<\/a>, Winlibs is a cool project that allows us to install both GCC and Clang on a windows machine.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"773\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/GCC-and-Clang-compilers-download-1024x773.png\" alt=\"GCC and Clang compilers download\" class=\"wp-image-909\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/GCC-and-Clang-compilers-download-1024x773.png 1024w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/GCC-and-Clang-compilers-download-300x227.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/GCC-and-Clang-compilers-download-768x580.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/GCC-and-Clang-compilers-download-100x76.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/GCC-and-Clang-compilers-download-596x450.png 596w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/GCC-and-Clang-compilers-download-600x453.png 600w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/GCC-and-Clang-compilers-download.png 1335w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>I recommend you download the latest release which in my case is <strong>11.2.0<\/strong> but by the time you&#8217;ll be reading this article the version might change.<\/p>\n\n\n\n<p>Please grab the latest version and also I want you to download the version that has both <strong>GCC + LLVM\/Clang\/LLD\/LLDB<\/strong>.<\/p>\n\n\n\n<p>For the runtime, you can use <strong>UCRT runtime<\/strong> if you are on Windows 10 and above but if you targeting an older version of Windows then you can use the <strong>MSVCRT<\/strong> <strong>runtime<\/strong>.<\/p>\n\n\n\n<p>Since am using Windows 11 am going to install the version that uses the UCRT runtime.<\/p>\n\n\n\n<p>One last thing, if you are on a <strong>32 bits<\/strong> Windows machine then download the version that has <strong>Win32,<\/strong> and also if you are on a <strong>64 bits<\/strong> Windows machine then download the version that has <strong>Win64<\/strong>.<\/p>\n\n\n\n<p>After the download is complete, you need to extract the <strong>Mingw64<\/strong> folder from the zip file to a location on your <strong>C drive<\/strong>.<\/p>\n\n\n\n<p>Now that you have the Mingw64 folder on your <strong>C drive<\/strong>, open it then click on the <strong>bin<\/strong> folder and copy the path.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"633\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/add-path-to-environment-variables-1024x633.png\" alt=\"add path to environment variables\" class=\"wp-image-913\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/add-path-to-environment-variables-1024x633.png 1024w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/add-path-to-environment-variables-300x185.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/add-path-to-environment-variables-768x475.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/add-path-to-environment-variables-100x62.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/add-path-to-environment-variables-700x433.png 700w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/add-path-to-environment-variables-600x371.png 600w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/add-path-to-environment-variables.png 1113w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Open the windows menu by clicking the Windows key then search for <strong>env<\/strong> and click on <strong>Edit the System Environment Variables<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"767\" height=\"717\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/environment-variable-search-menu.png\" alt=\"environment variable search menu\" class=\"wp-image-914\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/environment-variable-search-menu.png 767w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/environment-variable-search-menu-300x280.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/environment-variable-search-menu-100x93.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/environment-variable-search-menu-481x450.png 481w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/environment-variable-search-menu-600x561.png 600w\" sizes=\"auto, (max-width: 767px) 100vw, 767px\" \/><\/figure>\n\n\n\n<p>A popup of the System Properties will be displayed, click on the Environment Variables Tab under the <strong>Startup and Recovery<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"402\" height=\"462\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/system-property.png\" alt=\"system property\" class=\"wp-image-916\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/system-property.png 402w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/system-property-261x300.png 261w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/system-property-87x100.png 87w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/system-property-392x450.png 392w\" sizes=\"auto, (max-width: 402px) 100vw, 402px\" \/><\/figure>\n\n\n\n<p>A popup will show, under System Variables scroll down and select <strong>Path<\/strong> and click on <strong>Edit<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"610\" height=\"576\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/environment-variables.png\" alt=\"environment variables\" class=\"wp-image-915\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/environment-variables.png 610w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/environment-variables-300x283.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/environment-variables-100x94.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/environment-variables-477x450.png 477w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/environment-variables-600x567.png 600w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/figure>\n\n\n\n<p>Then another popup will be displayed, click <strong>New<\/strong> and paste the Path we copied from the<strong> bin<\/strong> folder in the <strong>Mingw64<\/strong> folder.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"519\" height=\"490\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/new-environment-variable.png\" alt=\"new environment variable\" class=\"wp-image-917\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/new-environment-variable.png 519w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/new-environment-variable-300x283.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/new-environment-variable-100x94.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/new-environment-variable-477x450.png 477w\" sizes=\"auto, (max-width: 519px) 100vw, 519px\" \/><\/figure>\n\n\n\n<p>Now click on the <strong>Ok<\/strong> buttons on the various popups to close them.<\/p>\n\n\n\n<p>One way to test if your G++ and Clang++ compilers are working is to open a command-line tool like cmd.<\/p>\n\n\n\n<p>Run the <code>g++ --version<\/code> and you should see some information about the G++ compiler including the version.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"504\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/checking-if-g-and-clang-compilers-are-working.png\" alt=\"checking if g++ and clang++ compilers are working\" class=\"wp-image-919\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/checking-if-g-and-clang-compilers-are-working.png 969w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/checking-if-g-and-clang-compilers-are-working-300x156.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/checking-if-g-and-clang-compilers-are-working-768x399.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/checking-if-g-and-clang-compilers-are-working-100x52.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/checking-if-g-and-clang-compilers-are-working-700x364.png 700w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/checking-if-g-and-clang-compilers-are-working-600x312.png 600w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/><\/figure>\n\n\n\n<p>For the Clang compiler, run <code>clang++ --version<\/code> and you&#8217;ll see some information about the Clang compiler including the version.<\/p>\n\n\n\n<p>In brief, these are the compilers we can use to write a C++20 application.<\/p>\n\n\n\n<p>Now we have the GCC and the Clang LLVM compilers on our system through the MingW64 project.<\/p>\n\n\n\n<p>It&#8217;s now time to install the <strong>Msvc<\/strong> compiler by Microsoft.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-to-install-msvc-compiler\">How to install Msvc compiler<\/h3>\n\n\n\n<p>To get a hold of the <strong>Msvc<\/strong> compiler you need to install Microsoft Visual Studio.<\/p>\n\n\n\n<p>Navigate to the <a href=\"https:\/\/visualstudio.microsoft.com\/vs\/older-downloads\/#visual-studio-2019-and-other-products\" target=\"_blank\" rel=\"noopener\">Microsoft Visual Studio 2019 download page<\/a> &#8211; Microsoft Visual Studio 2019 has a community, Professional, and Enterprise version but we are going to install the community version since it&#8217;s enough to write C++ programs.<\/p>\n\n\n\n<p>At the time of writing this article, Visual Studio 2019 is the latest version but if you find a newer version then don&#8217;t hesitate to download it. <\/p>\n\n\n\n<p>After the download is complete, click on the Visual Studio 2019 installer and you should see a window like this.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"572\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/visual-studio-2019-installer-1024x572.png\" alt=\"visual studio 2019 installer\" class=\"wp-image-925\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/visual-studio-2019-installer-1024x572.png 1024w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/visual-studio-2019-installer-300x167.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/visual-studio-2019-installer-768x429.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/visual-studio-2019-installer-100x56.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/visual-studio-2019-installer-700x391.png 700w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/visual-studio-2019-installer-600x335.png 600w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/visual-studio-2019-installer.png 1272w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The window will give you a gist of all the tools you can install to use with the Microsoft Visual Studio IDE.<\/p>\n\n\n\n<p>You should tick the <strong>Desktop development with C++<\/strong> since we are interested in C++ and click on the download dropdown and select <strong>Install while downloading<\/strong>.<\/p>\n\n\n\n<p>Once you click on <strong>Install while downloading<\/strong>, the installer will download the Visual Studio IDE and the MSVC compiler with the underlying compilers and some helpful tools we really need to write C++ applications.<\/p>\n\n\n\n<p>Now we have three C++ compilers on our windows machine that we can use for C++ development.<\/p>\n\n\n\n<p>We have the GCC compiler, Clang LLVM compiler, and MSVM compiler from Microsoft.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"the-c-compilers-for-mac-computer\">The C++ Compilers for Mac Computer<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>GCC <\/li><li>Clang llvm<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"the-c-compilers-for-linux-computer\">The C++ Compilers for Linux Computer<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>GCC<\/li><li>Clang Apple<\/li><li>Clang llvm<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"download-visual-studio-code-vs-code-editor\">Download Visual Studio Code (VS Code) Editor<\/h2>\n\n\n\n<p>Now we need to install an IDE which is VS Code that we can connect to the three compilers so that we can start writing our C++ programs.<\/p>\n\n\n\n<p>Search for VS Code in your browser and click on the first link or click here to navigate to the download page of VS Code.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"735\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/vscode-download-search-1024x735.png\" alt=\"vscode download search\" class=\"wp-image-931\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/vscode-download-search-1024x735.png 1024w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/vscode-download-search-300x215.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/vscode-download-search-768x551.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/vscode-download-search-100x72.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/vscode-download-search-627x450.png 627w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/vscode-download-search-600x431.png 600w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/vscode-download-search.png 1462w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>You can read more about it in the short description, you can see it&#8217;s supported on Windows, Linux, and macOS.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"795\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/vscode-download-page-1024x795.png\" alt=\"vscode download page\" class=\"wp-image-930\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/vscode-download-page-1024x795.png 1024w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/vscode-download-page-300x233.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/vscode-download-page-768x596.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/vscode-download-page-100x78.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/vscode-download-page-580x450.png 580w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/vscode-download-page-600x466.png 600w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/vscode-download-page.png 1300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Scroll down to this section and click on the download button depending on your operating system.<\/p>\n\n\n\n<p>After the download is complete, click on the installer then accept the agreement and click Next.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"589\" height=\"457\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/accept-vscode-agreement.png\" alt=\"accept vscode agreement\" class=\"wp-image-976\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/accept-vscode-agreement.png 589w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/accept-vscode-agreement-300x233.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/accept-vscode-agreement-100x78.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/accept-vscode-agreement-580x450.png 580w\" sizes=\"auto, (max-width: 589px) 100vw, 589px\" \/><\/figure>\n\n\n\n<p>Make sure you check the following options shown in the image below and click on the Next button to install it.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"591\" height=\"458\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/checked-options.png\" alt=\"checked options\" class=\"wp-image-977\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/checked-options.png 591w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/checked-options-300x232.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/checked-options-100x77.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/checked-options-581x450.png 581w\" sizes=\"auto, (max-width: 591px) 100vw, 591px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"install-essential-extensions-and-ai-tools\">Install essential extensions and AI tools<\/h2>\n\n\n\n<p>Now open VS Code and you should see a welcome message with some other helpful information you can read.<\/p>\n\n\n\n<p>The first thing we have to do is to install some extensions to help ease our C++ development.<\/p>\n\n\n\n<p>To access the Extensions market, click on <strong>View<\/strong> in the menu and select <strong>Extensions,<\/strong> or from the sidebar icons click on the extension icon.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"872\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/extension-tab-in-vscode-1024x872.png\" alt=\"extension tab in vscode\" class=\"wp-image-947\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/extension-tab-in-vscode-1024x872.png 1024w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/extension-tab-in-vscode-300x256.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/extension-tab-in-vscode-768x654.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/extension-tab-in-vscode-100x85.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/extension-tab-in-vscode-528x450.png 528w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/extension-tab-in-vscode-600x511.png 600w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/extension-tab-in-vscode.png 1268w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Here is a list of some of the essential VS Code extensions you can install to take your C++ development to the next level.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-vscode.cpptools\" target=\"_blank\" rel=\"noreferrer noopener\">C\/C++ IntelliSense, debugging, and code browsing<\/a><br><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"253\" class=\"wp-image-936\" style=\"width: 800px;\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/c-vscode-extension.png\" alt=\"c++ vscode extension\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/c-vscode-extension.png 1194w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/c-vscode-extension-300x95.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/c-vscode-extension-1024x323.png 1024w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/c-vscode-extension-768x242.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/c-vscode-extension-100x32.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/c-vscode-extension-700x221.png 700w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/c-vscode-extension-600x189.png 600w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/li><li><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=xaver.clang-format\" target=\"_blank\" rel=\"noreferrer noopener\">Clang-Format<\/a><br><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"283\" class=\"wp-image-937\" style=\"width: 800px;\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/clang-format-c-vs-code-extensioin.png\" alt=\"clang-format c++ vs code extensioin\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/clang-format-c-vs-code-extensioin.png 1076w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/clang-format-c-vs-code-extensioin-300x106.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/clang-format-c-vs-code-extensioin-1024x362.png 1024w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/clang-format-c-vs-code-extensioin-768x271.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/clang-format-c-vs-code-extensioin-100x35.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/clang-format-c-vs-code-extensioin-700x247.png 700w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/clang-format-c-vs-code-extensioin-600x212.png 600w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/li><li><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=TabNine.tabnine-vscode\" target=\"_blank\" rel=\"noreferrer noopener\">Tabnine AI Autocomplete<\/a><br><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"281\" class=\"wp-image-944\" style=\"width: 800px;\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/tabnine-ai-extension-vscode.png\" alt=\"tabnine ai extension vscode\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/tabnine-ai-extension-vscode.png 1317w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/tabnine-ai-extension-vscode-300x105.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/tabnine-ai-extension-vscode-1024x360.png 1024w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/tabnine-ai-extension-vscode-768x270.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/tabnine-ai-extension-vscode-100x35.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/tabnine-ai-extension-vscode-700x246.png 700w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/tabnine-ai-extension-vscode-600x211.png 600w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/li><li><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=GitHub.copilot\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub Copilot<\/a><br><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"275\" class=\"wp-image-939\" style=\"width: 800px;\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Github-copilot-vs-code-extension-for-c.png\" alt=\"Github copilot vs code extension for c++\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Github-copilot-vs-code-extension-for-c.png 1092w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Github-copilot-vs-code-extension-for-c-300x103.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Github-copilot-vs-code-extension-for-c-1024x353.png 1024w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Github-copilot-vs-code-extension-for-c-768x264.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Github-copilot-vs-code-extension-for-c-100x34.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Github-copilot-vs-code-extension-for-c-700x241.png 700w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Github-copilot-vs-code-extension-for-c-600x207.png 600w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/li><li><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=PKief.material-icon-theme\" target=\"_blank\" rel=\"noreferrer noopener\">Material Icon Theme<\/a><br><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"259\" class=\"wp-image-941\" style=\"width: 800px;\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Material-icons-vs-code-extension.png\" alt=\"Material icons vs code extension\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Material-icons-vs-code-extension.png 1160w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Material-icons-vs-code-extension-300x97.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Material-icons-vs-code-extension-1024x332.png 1024w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Material-icons-vs-code-extension-768x249.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Material-icons-vs-code-extension-100x32.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Material-icons-vs-code-extension-700x227.png 700w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Material-icons-vs-code-extension-600x194.png 600w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/li><li><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=eamodio.gitlens\" target=\"_blank\" rel=\"noreferrer noopener\">GitLens \u2014 Git supercharged<\/a><br><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"268\" class=\"wp-image-940\" style=\"width: 800px;\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Gitlens-vscode-extension-for-c.png\" alt=\"Gitlens vscode extension for c++\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Gitlens-vscode-extension-for-c.png 1356w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Gitlens-vscode-extension-for-c-300x101.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Gitlens-vscode-extension-for-c-1024x344.png 1024w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Gitlens-vscode-extension-for-c-768x258.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Gitlens-vscode-extension-for-c-100x34.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Gitlens-vscode-extension-for-c-700x235.png 700w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/Gitlens-vscode-extension-for-c-600x201.png 600w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/li><li><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=sdras.night-owl\" target=\"_blank\" rel=\"noreferrer noopener\">Night Owl Theme<\/a><br><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"261\" class=\"wp-image-945\" style=\"width: 800px;\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/owl-night-theme-for-c-development.png\" alt=\"owl night theme for c++ development\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/owl-night-theme-for-c-development.png 1175w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/owl-night-theme-for-c-development-300x98.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/owl-night-theme-for-c-development-1024x334.png 1024w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/owl-night-theme-for-c-development-768x250.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/owl-night-theme-for-c-development-100x33.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/owl-night-theme-for-c-development-700x228.png 700w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/owl-night-theme-for-c-development-600x196.png 600w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"c-c-intellisense-debugging-and-code-browsing\">C\/C++ IntelliSense, debugging, and code browsing<\/h3>\n\n\n\n<p>The C\/C++ extension will help VS Code support C\/C++ so that you can get IntelliSense, autocompletion, and many more features when you are writing C++ code.<\/p>\n\n\n\n<p>By default, the C\/C++ extension does not come with the different compilers to compile our human-readable C++ code to an executable binary file.<\/p>\n\n\n\n<p>That is the reason why we had to install the different C++ compilers before installing the C\/C++ extension. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"tabnine-ai-autocomplete\">Tabnine AI Autocomplete<\/h3>\n\n\n\n<p><a href=\"https:\/\/www.tabnine.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Tabnine AI Autocomplete<\/a> extension is an AI tool that makes suggestions while you type. <\/p>\n\n\n\n<p>Tabnine now supports 23 mainstream programming languages and five text editors.<\/p>\n\n\n\n<p>Sometimes when am writing code I have the feeling of &#8220;Wow&#8221; how did it know what I wanted to type?<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"material-icon-theme\">Material Icon Theme<\/h3>\n\n\n\n<p>VS Code by default comes with icons that are not that great so when you install an icon library like <strong>Material Icon theme<\/strong> it can make your editor look professional.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-make-vs-code-use-the-compilers-we-installed\">How to make VS Code use the Compilers we Installed<\/h2>\n\n\n\n<p>Now we need to connect VS Code editor to the compilers we installed so that we can compile our C++ applications easily through the Visual Studio Code editor.<\/p>\n\n\n\n<p>What we are going to do is to set up a C++ template project we can use in all the applications we&#8217;ll be building.<\/p>\n\n\n\n<p>We only need to copy the configuration files from the template folder and then paste them into the new project and we are good to go.<\/p>\n\n\n\n<p>Create an empty folder on your computer then right-click on it and select Open with VS Code.<\/p>\n\n\n\n<p>Once you&#8217;ve opened your template folder with VS Code, create a <code>main.cpp<\/code> file and paste the code snippets below into it.<\/p>\n\n\n\n<pre class=\"line-numbers language-cpp\"><code>\n#include &lt;iostream&gt;\nint main() {\n  auto result = (10 &lt;=&gt; 20) &gt; 0;\n  std::cout &lt;&lt; \"result: \" &lt;&lt; result &lt;&lt; std::endl;\n}\n<\/code>\n<\/pre>\n\n\n\n<p>The C++ code snippets above will help us know if our compilers support C++20.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-to-configure-gcc-compiler-in-vs-code\">How to Configure GCC Compiler in VS Code<\/h3>\n\n\n\n<p>From VS Code menu click on Terminal and select Configure Task from the list.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"770\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/configure-task-for-vscode-1024x770.png\" alt=\"configure task for vscode\" class=\"wp-image-953\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/configure-task-for-vscode-1024x770.png 1024w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/configure-task-for-vscode-300x226.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/configure-task-for-vscode-768x578.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/configure-task-for-vscode-100x75.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/configure-task-for-vscode-600x451.png 600w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/configure-task-for-vscode-598x450.png 598w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/configure-task-for-vscode.png 1150w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Once you click on Configure Tasks then VS Code will go ahead and find all the compilers we installed on our system.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"699\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/all-the-compilers-we-installed-1024x699.png\" alt=\"all the compilers we installed\" class=\"wp-image-952\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/all-the-compilers-we-installed-1024x699.png 1024w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/all-the-compilers-we-installed-300x205.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/all-the-compilers-we-installed-768x524.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/all-the-compilers-we-installed-100x68.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/all-the-compilers-we-installed-659x450.png 659w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/all-the-compilers-we-installed-600x410.png 600w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/all-the-compilers-we-installed.png 1040w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>You can see <strong>C\/C++:g++.exe<\/strong> and <strong>C\/C++:clang++.exe<\/strong> which are the two compilers we installed with the Mingw project.<\/p>\n\n\n\n<p>So we want to configure these two compilers to make VS Code use them to compile our C++ program.<\/p>\n\n\n\n<p>Click on the <strong>C\/C++:g++.exe<\/strong> compiler first and a Tasks.json file will be created in your project.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"745\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/tasks.json-file-1024x745.png\" alt=\"tasks.json file\" class=\"wp-image-956\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/tasks.json-file-1024x745.png 1024w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/tasks.json-file-300x218.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/tasks.json-file-768x559.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/tasks.json-file-100x73.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/tasks.json-file-618x450.png 618w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/tasks.json-file-600x437.png 600w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/tasks.json-file.png 1484w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Since the <code>main.cpp<\/code> program is using C++20 we need to configure our compiler to also use C++20.<\/p>\n\n\n\n<p>Now we need to select the <code>main.cpp<\/code> file and click on Terminal from the VS Code menu then click on Run Task.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"657\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/run-task-on-vscode-1024x657.png\" alt=\"run task on vscode\" class=\"wp-image-957\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/run-task-on-vscode-1024x657.png 1024w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/run-task-on-vscode-300x193.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/run-task-on-vscode-768x493.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/run-task-on-vscode-100x64.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/run-task-on-vscode-700x450.png 700w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/run-task-on-vscode-600x385.png 600w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/run-task-on-vscode.png 1092w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>A popup will display with the <strong>C\/C++:g++.exe<\/strong> compiler we configured. Click on the g++ compiler to compile our <code>main.cpp<\/code> file and a new terminal will open showing the build result.<\/p>\n\n\n\n<p>After the build has been completed successfully, a new <strong>main.exe<\/strong> file will be created in the project.<\/p>\n\n\n\n<p>Open a new terminal and run this command: <code>.\\main.exe<\/code> to execute the binary file and you should see the <strong>result: 0<\/strong> which is a good indication that we have our Visual Studio Code editor connected to our compiler.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-to-configure-the-clang-compiler-in-vs-code\">How to Configure the Clang++ Compiler in VS Code<\/h3>\n\n\n\n<p>Now it is time to also configure the Clang++ compiler so click on Terminal and then click on Configure Tasks.<\/p>\n\n\n\n<p>Look for <strong>C\/C++:Clang++.exe<\/strong> and click on it and this will add an entry in the Tasks.json file.<\/p>\n\n\n\n<p>Here are the full Tasks.json file configurations you can copy and paste into your Tasks.json file.<\/p>\n\n\n\n<p>Change the versions in the labels to match the version of <strong>g++<\/strong> and <strong>clang++<\/strong> you are using.<\/p>\n\n\n\n<pre class=\"line-numbers language-json\"><code>\n{\n  \"version\": \"2.0.0\",\n  \"tasks\": [\n    {\n      \"type\": \"cppbuild\",\n      \"label\": \"Build with GCC 11.2.0\",\n      \"command\": \"C:\\\\mingw64\\\\bin\\\\g++.exe\",\n      \"args\": [\n        \"-fdiagnostics-color=always\",\n        \"-g\",\n        \"-std=c++20\",\n        \"${workspaceFolder}\\\\*.cpp\",\n        \"-o\",\n        \"${fileDirname}\\\\${fileBasenameNoExtension}.exe\"\n      ],\n      \"options\": {\n        \"cwd\": \"${fileDirname}\"\n      },\n      \"problemMatcher\": [\"$gcc\"],\n      \"group\": \"build\",\n      \"detail\": \"compiler: C:\\\\mingw64\\\\bin\\\\g++.exe\"\n    },\n    {\n      \"type\": \"cppbuild\",\n      \"label\": \"Build with Clang 13.0.0\",\n      \"command\": \"C:\\\\mingw64\\\\bin\\\\clang++.exe\",\n      \"args\": [\n        \"-fdiagnostics-color=always\",\n        \"-g\",\n        \"-std=c++20\",\n        \"${workspaceFolder}\\\\*.cpp\",\n        \"-o\",\n        \"${fileDirname}\\\\${fileBasenameNoExtension}.exe\"\n      ],\n      \"options\": {\n        \"cwd\": \"${fileDirname}\"\n      },\n      \"problemMatcher\": [\"$gcc\"],\n      \"group\": \"build\",\n      \"detail\": \"compiler: C:\\\\mingw64\\\\bin\\\\clang++.exe\"\n    }\n  ]\n}\n<\/code>\n<\/pre>\n\n\n\n<p>Let&#8217;s test if our Clang++.exe compiler has been connected correctly with VS Code.<\/p>\n\n\n\n<p>Click on Terminal again then click on Run Task and from the available tasks runners click on the Clang compiler we just configured.<\/p>\n\n\n\n<p>A new terminal we open to show the build process and result. After the build has been completed, open a new terminal and run <code>.\\main.exe<\/code> to execute our binary executable file.<\/p>\n\n\n\n<p>You should still see the <strong>result: 0<\/strong> which is what we expected, if you have some kind of error then please contact me or leave a comment below and I will help you fix it.<\/p>\n\n\n\n<p>Now we have our two compilers working, the last compiler we need to configure is the Msvc compiler which is from Microsoft.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-to-configure-the-msvc-compiler-from-microsoft\">How to Configure the MSVC Compiler from Microsoft<\/h3>\n\n\n\n<p>Now we need to configure the C\/C++ VS Code extension to help it know we want to use C++20 so that it can give us C++20 IntelliSense.<\/p>\n\n\n\n<p>In VS Code use the shortcut (Ctrl + Shift + P) to open the command palette then search for <strong>C\/C++: Edit Configurations (UI)<\/strong> and click on it.<\/p>\n\n\n\n<p>Once you click on it a new <strong>c_cpp_properties.json<\/strong> file will be created in the <strong>.vscode<\/strong> configuration.<\/p>\n\n\n\n<p>Scroll down to the section where we have the C++ standard then change it to c++20 and close the configuration tab.<\/p>\n\n\n\n<p>If you go back to the C++20 code we wrote in the <code>main.cpp<\/code> file you&#8217;ll see that the code is no longer flagged as a programming error.<\/p>\n\n\n\n<p>Next, open the Windows menu then search for <strong>Developer PowerShell<\/strong> and click on the Developer PowerShell that matches the right community version.<\/p>\n\n\n\n<p>Run the command <strong>cl.exe<\/strong> and you should see some information about the Msvc compiler by Microsoft.<\/p>\n\n\n\n<p>What we are going to do is to set up a terminal like this and use this terminal to start up Visual Studio Code.<\/p>\n\n\n\n<p>This will make VS Code start in a mode where it can find the Msvc compiler by Microsoft.<\/p>\n\n\n\n<p>Open the File Explorer then navigate to the project folder and copy the path to the project.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"621\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/cpp-project-path-for-msvc-compiler-1024x621.png\" alt=\"cpp project path for msvc compiler\" class=\"wp-image-984\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/cpp-project-path-for-msvc-compiler-1024x621.png 1024w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/cpp-project-path-for-msvc-compiler-300x182.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/cpp-project-path-for-msvc-compiler-768x466.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/cpp-project-path-for-msvc-compiler-100x61.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/cpp-project-path-for-msvc-compiler-700x425.png 700w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/cpp-project-path-for-msvc-compiler-600x364.png 600w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/cpp-project-path-for-msvc-compiler.png 1118w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Go back to the Developer PowerShell and change the directory to the C++ template path we copied.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"970\" height=\"504\" src=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/change-directory-to-cpp-project.png\" alt=\"change directory to cpp project\" class=\"wp-image-986\" srcset=\"https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/change-directory-to-cpp-project.png 970w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/change-directory-to-cpp-project-300x156.png 300w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/change-directory-to-cpp-project-768x399.png 768w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/change-directory-to-cpp-project-100x52.png 100w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/change-directory-to-cpp-project-700x364.png 700w, https:\/\/codevoweb.com\/wp-content\/uploads\/2022\/02\/change-directory-to-cpp-project-600x312.png 600w\" sizes=\"auto, (max-width: 970px) 100vw, 970px\" \/><\/figure>\n\n\n\n<p>Run this VS Code command <code>code .<\/code> to start VS Code in the current folder.<\/p>\n\n\n\n<p>The good thing about starting VS Code this way is it&#8217;s going to know about the compiler from Microsoft.<\/p>\n\n\n\n<p>Open your terminal and run <code>cl.exe<\/code> and you should see some information about the compiler from Microsoft.<\/p>\n\n\n\n<p>Now let&#8217;s configure VS Code to use the MSVC compiler, navigate to Terminal then click on <strong>Configure Tasks<\/strong>.<\/p>\n\n\n\n<p>Please make sure you&#8217;ve selected the <code>main.cpp<\/code> file else you won&#8217;t see all the compilers.<\/p>\n\n\n\n<p>Look for the Microsoft compiler <strong>C\/C++: cl.exe<\/strong> then click on it and a new configuration entry will be added to the <strong>tasks.json<\/strong> file.<\/p>\n\n\n\n<p>Here are the full configurations of the three compilers in the <strong>tasks.json<\/strong> file:<\/p>\n\n\n\n<pre class=\"line-numbers language-json\"><code>\n{\n  \"version\": \"2.0.0\",\n  \"tasks\": [\n    {\n      \"type\": \"cppbuild\",\n      \"label\": \"Build with GCC 11.2.0\",\n      \"command\": \"C:\\\\mingw64\\\\bin\\\\g++.exe\",\n      \"args\": [\n        \"-fdiagnostics-color=always\",\n        \"-g\",\n        \"-std=c++20\",\n        \"${workspaceFolder}\\\\*.cpp\",\n        \"-o\",\n        \"${fileDirname}\\\\${fileBasenameNoExtension}.exe\"\n      ],\n      \"options\": {\n        \"cwd\": \"${fileDirname}\"\n      },\n      \"problemMatcher\": [\"$gcc\"],\n      \"group\": \"build\",\n      \"detail\": \"compiler: C:\\\\mingw64\\\\bin\\\\g++.exe\"\n    },\n    {\n      \"type\": \"cppbuild\",\n      \"label\": \"Build with Clang 13.0.0\",\n      \"command\": \"C:\\\\mingw64\\\\bin\\\\clang++.exe\",\n      \"args\": [\n        \"-fdiagnostics-color=always\",\n        \"-g\",\n        \"-std=c++20\",\n        \"${workspaceFolder}\\\\*.cpp\",\n        \"-o\",\n        \"${fileDirname}\\\\${fileBasenameNoExtension}.exe\"\n      ],\n      \"options\": {\n        \"cwd\": \"${fileDirname}\"\n      },\n      \"problemMatcher\": [\"$gcc\"],\n      \"group\": \"build\",\n      \"detail\": \"compiler: C:\\\\mingw64\\\\bin\\\\clang++.exe\"\n    },\n    {\n      \"type\": \"cppbuild\",\n      \"label\": \"Build with MSVC\",\n      \"command\": \"cl.exe\",\n      \"args\": [\n        \"\/Zi\",\n        \"\/std:c++latest\",\n        \"\/EHsc\",\n        \"\/Fe:\",\n        \"${fileDirname}\\\\${fileBasenameNoExtension}.exe\",\n        \"${workspaceFolder}\\\\*.cpp\"\n      ],\n      \"options\": {\n        \"cwd\": \"${fileDirname}\"\n      },\n      \"problemMatcher\": [\"$msCompile\"],\n      \"group\": \"build\",\n      \"detail\": \"compiler: cl.exe\"\n    }\n  ]\n}\n\n<\/code>\n<\/pre>\n\n\n\n<p>Now let&#8217;s compile our <strong>main.exe<\/strong> program with the MSVC compiler to see if it supports C++20.<\/p>\n\n\n\n<p>Click on the Terminal menu then select Run Task and click on the MSVC compiler.<\/p>\n\n\n\n<p>Once you click on it, the compiler should compile your <strong>main.exe<\/strong> program to a binary executable file and it will also create some additional files in your project.<\/p>\n\n\n\n<p>After the build is complete, open a new terminal then run the <strong>main.exe<\/strong> binary file and you should see the <strong>result: 0<\/strong> which is what we expected.<\/p>\n\n\n\n<p>Next, delete all the junk files that were created by the MSVC compiler and also include the binary file.<\/p>\n\n\n\n<p>Now we have a starting template we can use to write C and C++ applications. <\/p>\n\n\n\n<p>Whenever you want to write a C++ project, you can copy and paste the configuration files in the C++ template into your new project.<\/p>\n\n\n\n<p>This will ensure that you don&#8217;t have to configure VS Code and the compilers anytime you want to write C++ programs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>In this article, I showed you how to set up VS Code for C++ development step by step from installing three different compilers to configuring them so that VS Code can use them to build our programs into a binary executable file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Visual Studio Code is an open-source editor developed by Microsoft and anyone with programming skills can customize it to meet their need. VS Code has&#8230;<\/p>\n","protected":false},"author":1,"featured_media":973,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[51],"tags":[52,27,26,30,53,33,32],"class_list":["post-899","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c","tag-c","tag-programmers","tag-programming-language","tag-vscode","tag-vscode-c","tag-vscode-extension","tag-vscode-tips-and-tricks"],"acf":[],"_links":{"self":[{"href":"https:\/\/codevoweb.com\/wp-json\/wp\/v2\/posts\/899","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codevoweb.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codevoweb.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codevoweb.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codevoweb.com\/wp-json\/wp\/v2\/comments?post=899"}],"version-history":[{"count":0,"href":"https:\/\/codevoweb.com\/wp-json\/wp\/v2\/posts\/899\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codevoweb.com\/wp-json\/wp\/v2\/media\/973"}],"wp:attachment":[{"href":"https:\/\/codevoweb.com\/wp-json\/wp\/v2\/media?parent=899"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codevoweb.com\/wp-json\/wp\/v2\/categories?post=899"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codevoweb.com\/wp-json\/wp\/v2\/tags?post=899"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}