{"id":27555,"date":"2021-02-09T16:00:05","date_gmt":"2021-02-09T16:00:05","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cppblog\/?p=27555"},"modified":"2021-02-09T15:58:48","modified_gmt":"2021-02-09T15:58:48","slug":"visual-studio-code-c-extension-cross-compilation-intellisense-configurations","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/visual-studio-code-c-extension-cross-compilation-intellisense-configurations\/","title":{"rendered":"Visual Studio Code C++ Extension: Cross-Compilation IntelliSense Configurations"},"content":{"rendered":"<p>The February 2021 update of the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-vscode.cpptools\">Visual Studio Code C++ extension<\/a> is now available! This latest release provides <a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/issues\/1083\">support for cross-compilation IntelliSense configurations<\/a> and over 60 bug fixes! To find out more about all the enhancements, check out our\u00a0<a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/releases\/tag\/1.2.0\">release notes on GitHub.<\/a><\/p>\n<h3>Cross-compilation IntelliSense configurations<\/h3>\n<p>With this latest release, you can configure the extension to provide proper IntelliSense when compiling for a different <em>platform<\/em> than your host OS. That\u2019s right\u2014 <em>platform<\/em>, not just architecture. The C++ extension no longer hardcodes system defines based on your host OS; it\u2019ll use the system defines returned by your compiler.<\/p>\n<p>Let\u2019s say you\u2019re developing on macOS and your project targets Linux. Assuming you have a compiler compatible with your project\u2019s target platform and architecture, the C++ extension will query that compiler using the <strong>Compiler path<\/strong>, <strong>Compiler arguments, <\/strong>and<strong> IntelliSense mode<\/strong> settings in your IntelliSense configuration. If you\u2019re using a custom configuration provider (like CMake Tools) or compile_commands.json, then you don\u2019t need to worry about updating the C++ extension\u2019s IntelliSense configuration; everything should just work.<\/p>\n<p>Your project\u2019s IntelliSense configurations are stored in the c_cpp_properties.json file under the .vscode folder. Edit these settings by selecting <strong>C\/C++: Edit Configurations (UI)<\/strong> from the Command Palette.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/edit-configurations.png\"><img decoding=\"async\" class=\"alignnone wp-image-27564 size-full\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/edit-configurations.png\" alt=\"The UI and JSON Edit Configurations options in the Command Palette\" width=\"1458\" height=\"237\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/edit-configurations.png 1458w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/edit-configurations-300x49.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/edit-configurations-1024x166.png 1024w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/edit-configurations-768x125.png 768w\" sizes=\"(max-width: 1458px) 100vw, 1458px\" \/><\/a><\/p>\n<p>Under your configuration\u2019s <strong>Compiler path <\/strong>setting<strong>, <\/strong>enter the path to the compiler compatible with your target platform and architecture.<\/p>\n<p>Then use <strong>Compiler arguments<\/strong> to provide the target triplet that you use when cross-compiling your code with your compiler. For example, <em>&#8211;target=x86_64-linux<\/em> if you\u2019re targeting Linux 64-bit. This allows the C++ extension to query the compiler for system defines and include paths specific to your target platform and architecture.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/compiler-args-1.png\"><img decoding=\"async\" class=\"alignnone wp-image-27562 size-full\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/compiler-args-1.png\" alt=\"Passing --target=x86_64-linux as a compiler argument\" width=\"1630\" height=\"308\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/compiler-args-1.png 1630w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/compiler-args-1-300x57.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/compiler-args-1-1024x193.png 1024w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/compiler-args-1-768x145.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/compiler-args-1-1536x290.png 1536w\" sizes=\"(max-width: 1630px) 100vw, 1630px\" \/><\/a><\/p>\n<p>Next, set <strong>IntelliSense mode<\/strong> to the platform- and architecture-specific variant of the compiler you\u2019re using (it should closely match the target triplet defined in <strong>Compiler arguments<\/strong>). If the information returned from querying the compiler doesn\u2019t match the <strong>IntelliSense mode <\/strong>you chose, the C++ extension will automatically correct the IntelliSense mode for you.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/intellisense-mode-1.png\"><img decoding=\"async\" class=\"alignnone wp-image-27563 size-full\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/intellisense-mode-1.png\" alt=\"Selecting linux-clang-x64 for IntelliSense mode\" width=\"1636\" height=\"314\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/intellisense-mode-1.png 1636w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/intellisense-mode-1-300x58.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/intellisense-mode-1-1024x197.png 1024w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/intellisense-mode-1-768x147.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/intellisense-mode-1-1536x295.png 1536w\" sizes=\"(max-width: 1636px) 100vw, 1636px\" \/><\/a><\/p>\n<p>Now when you open your project in VS Code, you\u2019ll get IntelliSense for your target platform instead of macOS. No more squiggles from hardcoded system defines!<\/p>\n<h3>Additional enhancements<\/h3>\n<p>In addition to supporting cross-compilation IntelliSense configurations, the February 2021 update comes with the following enhancements:<\/p>\n<ul>\n<li>clang-format has been updated to version 11. <a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/issues\/6326\">#6326<\/a><\/li>\n<li>We now ship a native ARM64 clang-format binary with the extension for ARM64 Windows devices (<a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/issues\/6494\">#6494<\/a>).<\/li>\n<li>We added a command to generate EditorConfig contents from your code formatting settings (vcFormat) <a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/issues\/6018\">#6018<\/a><\/li>\n<li>We support a new &#8220;console&#8221; launch config property for cppvsdbg (replacing the legacy \u201cexternalConsole\u201d property).\u00a0<a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/pull\/6794\">PR #6794<\/a><\/li>\n<\/ul>\n<h3>Bug Fixes<\/h3>\n<p>The February 2021 update of the C++ extension knocks out over 60 bug fixes! To name a few:<\/p>\n<ul>\n<li>Fix clang-format failing due to missing libtinfo5 on Linux ARM\/ARM64.\u00a0<a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/pull\/6774\">#6774<\/a><\/li>\n<li>Fix handling of\u00a0&#8211;sysrootand\u00a0-isysroot\u00a0with\u00a0compileCommands.\u00a0<a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/issues\/1575\">#1575<\/a><\/li>\n<li>Fix IntelliSense not updating if a non-opened header is changed.\u00a0<a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/issues\/1780\">#1780<\/a><\/li>\n<li>Fix Switch Header\/Source not switching to an existing file in another column if it&#8217;s not visible.\u00a0<a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/issues\/2667\">#2667<\/a>,\u00a0<a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/issues\/6749\">#6749<\/a><\/li>\n<li>Allow the extension to run on x64 emulator of M1 Macs.\u00a0<a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/issues\/6713\">#6713<\/a> (Thank you <a href=\"https:\/\/github.com\/xymeng16\"><strong>@xymeng16<\/strong><\/a>! <a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/pull\/6601\">PR #6601<\/a>)<\/li>\n<li>Fix hover and Find All References for template function overloads.\u00a0<a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/issues\/4044\">#4044<\/a>,\u00a0<a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/issues\/4249\">#4249<\/a><\/li>\n<\/ul>\n<p>Check out <a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/releases\/tag\/1.2.0\">the release notes<\/a> for more!<\/p>\n<h3>What do you\u00a0think?<\/h3>\n<p><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-vscode.cpptools\">Download the C++ extension for Visual Studio Code<\/a>\u00a0today, give it a try, and let us know what you think. If you run into any issues, or have any suggestions, please report them in the\u00a0<a href=\"https:\/\/github.com\/Microsoft\/vscode-cpptools\/issues\">Issues section of our GitHub repository<\/a>. You can also join our Insiders program and get access to early builds of our release by going to\u00a0<strong>File<\/strong>\u00a0&gt;\u00a0<strong>Preferences<\/strong>\u00a0&gt;\u00a0<strong>Settings<\/strong>\u00a0and under\u00a0<strong>Extensions<\/strong>\u00a0&gt;\u00a0<strong>C\/C++,<\/strong>\u00a0change the \u201c<strong>C_Cpp: Update Channel<\/strong>\u201d to \u201c<strong>Insiders<\/strong>.\u201d Then under <strong>Features <\/strong>&gt; <strong>Extensions<\/strong>, enable \u201c<strong>Extensions<\/strong>:<strong> Auto Update<\/strong>.\u201d<\/p>\n<p>We can be reached via the comments below or in email at\u00a0<a href=\"mailto:visualcpp@microsoft.com\">visualcpp@microsoft.com<\/a>. You can also find our team on Twitter at\u00a0<a href=\"https:\/\/twitter.com\/visualc\">@<\/a><a href=\"https:\/\/twitter.com\/visualc\">VisualC<\/a>.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The February 2021 update of the Visual Studio Code C++ extension is now available! This latest release provides support for cross-compilation IntelliSense configurations and over 60 bug fixes! To find out more about all the enhancements, check out our\u00a0release notes on GitHub. Cross-compilation IntelliSense configurations With this latest release, you can configure the extension to [&hellip;]<\/p>\n","protected":false},"author":27203,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[270,1,275],"tags":[],"class_list":["post-27555","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-announcement","category-cplusplus","category-visual-studio-code"],"acf":[],"blog_post_summary":"<p>The February 2021 update of the Visual Studio Code C++ extension is now available! This latest release provides support for cross-compilation IntelliSense configurations and over 60 bug fixes! To find out more about all the enhancements, check out our\u00a0release notes on GitHub. Cross-compilation IntelliSense configurations With this latest release, you can configure the extension to [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/27555","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\/27203"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=27555"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/27555\/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=27555"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=27555"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=27555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}