{"id":33232,"date":"2023-11-15T17:05:20","date_gmt":"2023-11-15T17:05:20","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cppblog\/?p=33232"},"modified":"2023-11-27T11:06:41","modified_gmt":"2023-11-27T11:06:41","slug":"c-extension-in-vs-code-1-18-release-quick-fixes-for-missing-header-files-extract-to-function-more","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/c-extension-in-vs-code-1-18-release-quick-fixes-for-missing-header-files-extract-to-function-more\/","title":{"rendered":"C++ Extension in VS Code 1.18 Release: Quick Fixes for missing header files, Extract to Function &#038; More\u00a0"},"content":{"rendered":"<p aria-level=\"1\"><span data-contrast=\"none\">The <\/span><a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/releases\/tag\/v1.18.3\"><span data-contrast=\"none\">1.18 version<\/span><\/a><span data-contrast=\"none\">\u202fof the C++ Extension in Visual Studio Code has been released. With this version of the extension,\u202fwe have added several new features such as:\u00a0<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<ul>\n<li data-leveltext=\"-\" data-font=\"Segoe UI\" data-listid=\"5\" data-list-defn-props=\"{&quot;335551671&quot;:0,&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Segoe UI&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;-&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"0\" data-aria-level=\"1\"><span data-contrast=\"none\">Quick Fixes for missing header files<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Extract to function\/member function<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/li>\n<li data-leveltext=\"-\" data-font=\"Segoe UI\" data-listid=\"5\" data-list-defn-props=\"{&quot;335551671&quot;:0,&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Segoe UI&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;-&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"0\" data-aria-level=\"1\"><span data-contrast=\"none\">Assistance acquiring a compiler<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/li>\n<\/ul>\n<p><span data-contrast=\"none\">\u00a0For the full list of changes, please reference the <\/span><a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/releases\/tag\/v1.18.3\"><span data-contrast=\"none\">1.18 release notes<\/span><\/a><span data-contrast=\"none\">.\u00a0<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<h2><span style=\"font-size: 18pt;\">Quick Fixes for missing header files\u00a0<\/span><\/h2>\n<p><span data-contrast=\"none\">Have you ever written C++ code and forgotten to add the right header? Gotten frustrated because of an IntelliSense error that turns out to just be a missing header file? We have now added a quick fix suggestion (lightbulb) to make the process of adding the correct header files to C++ files easier. If there is an unknown symbol in your C++ code and the C\/C++ Extension identifies the correct header file in your workspace, you will now have a quick fix available. Select the quick fix and the necessary header file include will be added to the top of your current C++ file.<\/span><span data-contrast=\"none\">\u00a0<\/span><span data-ccp-props=\"{&quot;134245418&quot;:true,&quot;134245529&quot;:true}\">\u00a0<\/span><\/p>\n<p><span data-ccp-props=\"{&quot;335551550&quot;:2,&quot;335551620&quot;:2,&quot;335559739&quot;:240}\"><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/AddMissingIncludes-1.gif\"><img decoding=\"async\" class=\"aligncenter wp-image-33236\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/AddMissingIncludes-1.gif\" alt=\"a user selecting a variable with an underline, selecting the fixit and then selecting insert header. This adds the header to the top of their file.\" width=\"739\" height=\"290\" \/><\/a><\/span><\/p>\n<h2><span style=\"font-size: 18pt;\">Extract to Function\/Member Function\u00a0<\/span><\/h2>\n<p><span data-contrast=\"none\">One of the <\/span><a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/issues\/1162\"><span data-contrast=\"none\">most highly requested features<\/span><\/a><span data-contrast=\"none\"> for C++ in VS Code is support for extracting functions or member functions from code. With the 1.18 release, you can now select a section of your code, extract it into a separate function, and place a reference to the new function in the old location.\u00a0<\/span><span data-ccp-props=\"{&quot;335559739&quot;:0}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">To try this feature, select the C++ code you would like to extract. A code action (lightbulb) will appear with the option <strong>Extract to Function<\/strong>. Otherwise, right click on the code and select <strong>Refactor &gt; Extract<\/strong> or use the keyboard command Ctrl + Shift + R, Ctrl + E to get more information. As you can see below, you will then have the option to name the new function that has been created. The new function containing your highlighted code will be placed above the current function.<\/span><span data-ccp-props=\"{&quot;335559739&quot;:0}\">\u00a0<\/span><\/p>\n<p><span data-ccp-props=\"{&quot;335551550&quot;:2,&quot;335551620&quot;:2,&quot;335559739&quot;:0}\"> <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/ExtractMethodwithoutexperimentation.gif\"><img decoding=\"async\" class=\"aligncenter wp-image-33243\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/ExtractMethodwithoutexperimentation.gif\" alt=\"Image ExtractMethodwithoutexperimentation\" width=\"732\" height=\"411\" \/><\/a><\/span><\/p>\n<p><span data-contrast=\"none\">Upcoming improvements will further streamline the extraction process, such as being able to extract to a free function. Any feedback you have would be very valuable to share through<\/span> <a href=\"https:\/\/github.com\/Microsoft\/vscode-cpptools\/issues%22%20\/h%EF%B7%9FHYPERLINK%20%22https:\/\/github.com\/Microsoft\/vscode-cpptools\/issues\"><span data-contrast=\"none\">our GitHub issues<\/span><\/a><span data-contrast=\"none\"> to help us build the best experience<\/span><span data-contrast=\"none\">.\u00a0<\/span><span data-ccp-props=\"{&quot;335559739&quot;:0}\">\u00a0<\/span><\/p>\n<h2><span style=\"font-size: 18pt;\">New C++ Compiler Acquisition Process\u00a0<\/span><\/h2>\n<p><span data-contrast=\"none\">To streamline the C++ setup process, we have created an easier C++ compiler installation experience.\u00a0<\/span><span data-ccp-props=\"{&quot;335559739&quot;:0}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">For Mac and Linux users, you can now use the<strong> Install Compiler<\/strong> button to install a C++ compiler quickly and easily. The button will install a default C++ compiler on your system through the VS Code command line. This compiler will be automatically configured for IntelliSense. On a Mac, the default compiler installed is clang, while for supported Linux distros it is gcc and g++.\u00a0 To access this experience, you can use the C++ walkthrough or configuration quickpick.\u00a0<\/span><\/p>\n<p><span data-ccp-props=\"{&quot;335559739&quot;:0}\"> <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/install_a_compiler_mac-1.png\"><img decoding=\"async\" class=\"aligncenter wp-image-33238\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/install_a_compiler_mac-1.png\" alt=\"Image install a compiler mac, shows that for the configure intellisense command you can select install compiler\" width=\"570\" height=\"98\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/install_a_compiler_mac-1.png 1300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/install_a_compiler_mac-1-300x52.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/install_a_compiler_mac-1-1024x176.png 1024w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/install_a_compiler_mac-1-768x132.png 768w\" sizes=\"(max-width: 570px) 100vw, 570px\" \/><\/a><\/span><\/p>\n<p><span data-contrast=\"none\">To access the walkthrough, use the <strong>Open Walkthrough<\/strong> command in the command palette and select the <strong>Get Started with C++ Development<\/strong> option. Under the <strong>Set Up your C++ Environment<\/strong>, if you do not have a compiler already installed, you will see an <strong>Install Compiler<\/strong> button. <\/span><span data-ccp-props=\"{&quot;335559739&quot;:0}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">To access the IntelliSense configuration quick pick, enter the <strong>Select IntelliSense configuration<\/strong> command in the command palette. From the list, select the <strong>Install a Compiler<\/strong> option. A notification will open asking you to confirm the installation process. Select <strong>Install<\/strong>, which will open a terminal in VS Code and run the command line commands on your system to install the compiler. <\/span><span data-ccp-props=\"{&quot;335559739&quot;:0}\">\u00a0<\/span><\/p>\n<p><span data-ccp-props=\"{&quot;335559739&quot;:0}\"> <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/compiler-acquisition-clang.png\"><img decoding=\"async\" class=\"aligncenter wp-image-33239\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/compiler-acquisition-clang.png\" alt=\"Image compiler acquisition. Screenshot of the pop up notification that asks you to verify you are installing\" width=\"275\" height=\"266\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/compiler-acquisition-clang.png 702w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/compiler-acquisition-clang-300x291.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/compiler-acquisition-clang-24x24.png 24w\" sizes=\"(max-width: 275px) 100vw, 275px\" \/><\/a><\/span><\/p>\n<p><span data-contrast=\"none\">Note, you might need to enter your credentials in the command line to install the compiler on your system. \u00a0<\/span><span data-ccp-props=\"{&quot;335559739&quot;:0}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">On a Windows machine, we have added a new IntelliSense configuration menu option called <strong>Help me install a compiler.<\/strong> This option will provide you with the command needed to install the <\/span><span data-contrast=\"none\">Microsoft Visual C++ compiler<\/span> <span data-contrast=\"none\">(MSVC) on your system. Once you attest to having a valid <\/span><a href=\"https:\/\/visualstudio.microsoft.com\/license-terms\/vs2022-ga-diagnosticbuildtools\/\"><span data-contrast=\"none\">Visual Studio license<\/span><\/a><span data-contrast=\"none\">, then copy this command to your command line to run. <\/span><span data-ccp-props=\"{&quot;335559739&quot;:0}\">\u00a0<\/span><\/p>\n<p><span data-ccp-props=\"{&quot;335551550&quot;:2,&quot;335551620&quot;:2,&quot;335559739&quot;:0}\"> <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/msvc-install-command.png\"><img decoding=\"async\" class=\"aligncenter wp-image-33240\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/msvc-install-command.png\" alt=\"command to install msvc, find through the walkthrough. \" width=\"499\" height=\"163\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/msvc-install-command.png 2414w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/msvc-install-command-300x98.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/msvc-install-command-1024x334.png 1024w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/msvc-install-command-768x251.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/msvc-install-command-1536x501.png 1536w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/msvc-install-command-2048x669.png 2048w\" sizes=\"(max-width: 499px) 100vw, 499px\" \/><\/a><\/span><\/p>\n<h2 aria-level=\"2\"><span style=\"font-size: 18pt;\">Catching up: Adding Markdown support\u00a0\u00a0<\/span><\/h2>\n<p><span data-contrast=\"none\">Want to try out more C++ features? We recently added support for markdown when using the hover tooltip on comments. By default, the C++ Extension will now support showing a subset of markdown in your editor. This subset supports all markdown comments except the symbols \u201c_\u201d and \u201c*\u201d. Toggle the new <strong>Markdown in Comments<\/strong> setting to enable all markdown, keep this subset of markdown, or disable markdown support. <\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<p><span data-ccp-props=\"{&quot;335551550&quot;:2,&quot;335551620&quot;:2}\"> <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/markdownsupport.png\"><img decoding=\"async\" class=\"aligncenter wp-image-33242\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/markdownsupport.png\" alt=\"Image markdownsupport\" width=\"530\" height=\"296\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/markdownsupport.png 1924w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/markdownsupport-300x167.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/markdownsupport-1024x572.png 1024w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/markdownsupport-768x429.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2023\/11\/markdownsupport-1536x857.png 1536w\" sizes=\"(max-width: 530px) 100vw, 530px\" \/><\/a><\/span><\/p>\n<p><span data-contrast=\"none\">We also added a number of other enhancements such as extending support for gcc 13 features, additional compiler detection for MSYS compilers, and support for additional compiler wrappers. See the full release notes <a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/releases\/tag\/v1.17.2\">here<\/a>.\u00a0<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<h2><span style=\"font-size: 18pt;\">What do you think?\u00a0\u00a0<\/span><\/h2>\n<p><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-vscode.cpptools\"><span data-contrast=\"none\">Download the C\/C++ extension for Visual Studio Code <\/span><\/a><span data-contrast=\"none\">today, give it a try, and let us know what you think.\u00a0<\/span><span data-ccp-props=\"{&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">If you have any questions around this release, feel free to start a discussion in <\/span><a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/discussions\"><span data-contrast=\"none\">our GitHub repository.<\/span><\/a><span data-contrast=\"none\"> Otherwise, if you run into any issues, please report them in the\u202f<\/span><a href=\"https:\/\/github.com\/Microsoft\/vscode-cpptools\/issues\"><span data-contrast=\"none\">issues section<\/span><\/a><span data-contrast=\"none\">. We can be reached via the comments below, per email at\u202f <\/span><a href=\"mailto:visualcpp@microsoft.com\"><span data-contrast=\"none\">visualcpp@microsoft.com,<\/span><\/a><span data-contrast=\"none\"> or through our team on X\/Twitter at \u202f<\/span><a href=\"https:\/\/twitter.com\/visualc\"><span data-contrast=\"none\">@<\/span><\/a><a href=\"https:\/\/twitter.com\/visualc\"><span data-contrast=\"none\">VisualC.<\/span><\/a><span data-ccp-props=\"{&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<p><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<p><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<p><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The 1.18 version\u202fof the C++ Extension in Visual Studio Code has been released. With this version of the extension,\u202fwe have added several new features such as:\u00a0\u00a0 Quick Fixes for missing header files\u00a0 Extract to function\/member function\u00a0 Assistance acquiring a compiler\u00a0 \u00a0For the full list of changes, please reference the 1.18 release notes.\u00a0\u00a0 Quick Fixes for [&hellip;]<\/p>\n","protected":false},"author":101195,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[140,274,65,14,276],"class_list":["post-33232","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus","tag-c","tag-c-extension","tag-compiler","tag-intellisense","tag-vscode"],"acf":[],"blog_post_summary":"<p>The 1.18 version\u202fof the C++ Extension in Visual Studio Code has been released. With this version of the extension,\u202fwe have added several new features such as:\u00a0\u00a0 Quick Fixes for missing header files\u00a0 Extract to function\/member function\u00a0 Assistance acquiring a compiler\u00a0 \u00a0For the full list of changes, please reference the 1.18 release notes.\u00a0\u00a0 Quick Fixes for [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/33232","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/101195"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=33232"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/33232\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=33232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=33232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=33232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}