{"id":29854,"date":"2021-12-06T15:20:01","date_gmt":"2021-12-06T15:20:01","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cppblog\/?p=29854"},"modified":"2021-12-06T15:23:55","modified_gmt":"2021-12-06T15:23:55","slug":"makefile-tools-december-2021-update-problem-matchers-and-compilation-database-generation","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/makefile-tools-december-2021-update-problem-matchers-and-compilation-database-generation\/","title":{"rendered":"Makefile Tools December 2021 Update: Problem Matchers and Compilation Database Generation"},"content":{"rendered":"<p>The December 2021 update of\u00a0<a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-vscode.makefile-tools\">the Makefile Tools extension for Visual Studio Code<\/a>\u00a0is here, bringing you <a href=\"https:\/\/github.com\/microsoft\/vscode-makefile-tools\/issues\/7\">support for problem matchers<\/a> (to easily view errors and warnings in the editor), the ability to <a href=\"https:\/\/github.com\/microsoft\/vscode-makefile-tools\/issues\/104\">generate a compile_commands.json file<\/a> for your project, and a bunch of other enhancements and bug fixes! To find out more about all the enhancements, check out\u00a0our\u00a0<a href=\"https:\/\/github.com\/microsoft\/vscode-makefile-tools\/releases\/tag\/v0.3.0\">release notes on GitHub.<\/a><\/p>\n<h2>Problem matchers<\/h2>\n<p>If you\u2019ve used the C++ extension for VS Code, you\u2019re probably familiar with the <strong>Problems<\/strong> panel, where you can navigate through a list of compiler errors and warnings found in your project. VS Code uses a <a href=\"https:\/\/code.visualstudio.com\/Docs\/editor\/tasks#_processing-task-output-with-problem-matchers\">problem matcher<\/a> to display the errors and warnings in the Problems panel.<\/p>\n<p>For example, if you\u2019re missing a semi-colon in your source file, you\u2019ll see the compiler error in the <strong>Problems<\/strong> panel. Selecting the problem brings you to the line of code generating the error or warning. To fix the problem, click on the lightbulb and choose from a list of Quick Actions.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-problem-selected-2.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-29856\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-problem-selected-2.png\" alt=\"A screenshot of the Problems Pane in VS Code, showing errors and warnings found by GCC and make in the project\" width=\"3036\" height=\"2054\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-problem-selected-2.png 3036w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-problem-selected-2-300x203.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-problem-selected-2-1024x693.png 1024w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-problem-selected-2-768x520.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-problem-selected-2-1536x1039.png 1536w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-problem-selected-2-2048x1386.png 2048w\" sizes=\"(max-width: 3036px) 100vw, 3036px\" \/><\/a><\/p>\n<p>Now, let\u2019s say you don\u2019t have any compiler errors, but make displays a bunch of warnings when you build your project. Until now, there wasn\u2019t a way to see those warnings in the Problems panel. With this latest release of the Makefile Tools extension, you\u2019ll see all of make\u2019s errors and warnings in the Problems panel after you build your program.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-warnings.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-29857\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-warnings.png\" alt=\"A screenshot showing make's warnings in the Problems Pane in VS Code after building a project with Makefile Tools.\" width=\"3036\" height=\"2062\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-warnings.png 3036w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-warnings-300x204.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-warnings-1024x695.png 1024w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-warnings-768x522.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-warnings-1536x1043.png 1536w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-warnings-2048x1391.png 2048w\" sizes=\"(max-width: 3036px) 100vw, 3036px\" \/><\/a><\/p>\n<p>To enable make errors and warnings in the Problems panel, add <strong>&#8220;problemMatchers&#8221;: [&#8220;$gcc&#8221;]<\/strong> to your makefile configuration in settings.json, like this:<\/p>\n<pre class=\"prettyprint\">\"makefile.configurations\": [\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 {\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \"name\": \"MyConfiguration\",\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \"problemMatchers\": [\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \"$gcc\"\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ],\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0 \"makeArgs\": [\"any\", \"other\", \"args\", \"you\", \"want\"]\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 },\r\n\r\n]<\/pre>\n<p>If you\u2019re on Windows using MSVC, set the problemMatcher to <strong>&#8220;$msCompile&#8221;<\/strong> instead of <strong>&#8220;$gcc&#8221;<\/strong>. Contributions from the community to support additional problem matchers are welcome! Problem matchers are defined in the extension\u2019s <a href=\"https:\/\/github.com\/microsoft\/vscode-makefile-tools\/blob\/main\/package.json#L198\">package.json<\/a> file.<\/p>\n<h2>Generate compile_commands.json<\/h2>\n<p>As a C++ developer, you might find yourself wanting a compilation database, which is a file that stores compilation instructions for the source files in your project. Compilation databases are used by many <a href=\"https:\/\/clang.llvm.org\/docs\/ClangTools.html\">Clang tools<\/a> and editors\/IDEs. A common compilation database format is compile_commands.json, which contains command objects, one for each translation unit in the project. Each command object specifies the translation unit\u2019s main file, the compile command, and the working directory where the compile command is run.<\/p>\n<p>With this latest release of the Makefile Tools extension, you can generate a compile_commands.json file for your project. All you have to do is specify the path to the target compile_commands.json file in settings.json, like this:<\/p>\n<pre class=\"prettyprint\">\"makefile.compileCommandsPath\": \".vscode\/compile_commands.json\"<\/pre>\n<p>Then configure your project to generate compile_commands.json at the specified location.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-compile-commands.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-29855\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-compile-commands.png\" alt=\"A screenshot of the contents of a compile_commands.json file generated by the Makefile Tools extension\" width=\"3088\" height=\"1888\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-compile-commands.png 3088w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-compile-commands-300x183.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-compile-commands-1024x626.png 1024w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-compile-commands-768x470.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-compile-commands-1536x939.png 1536w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/12\/makefile-tools-compile-commands-2048x1252.png 2048w\" sizes=\"(max-width: 3088px) 100vw, 3088px\" \/><\/a><\/p>\n<p>Thank you <a href=\"https:\/\/github.com\/rapgenic\">rapgenic<\/a> for the request and for contributing to this feature!<\/p>\n<h2>Give it a try<\/h2>\n<p><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-vscode.makefile-tools\">Download the Makefile Tools extension for Visual Studio Code<\/a>\u202ftoday, give it a try, and let us know what you think. Check out <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/now-announcing-makefile-support-in-visual-studio-code\/\">this blog post<\/a> to learn how to get started with Makefile Tools.<\/p>\n<p>If you run into any issues, or have any suggestions, please report them in the\u00a0<a href=\"https:\/\/github.com\/Microsoft\/vscode-makefile-tools\/issues\">Issues section of our GitHub repository<\/a>. Be sure to check out the <a href=\"https:\/\/github.com\/microsoft\/vscode-makefile-tools\/tree\/main\/docs\">Makefile Tools documentation<\/a> for troubleshooting tips and a list of tested repositories and their configuration instructions.<\/p>\n<p>We can be reached via the comments below or in email at\u00a0<a href=\"mailto:makefiletools@microsoft.com\">makefiletools@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<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The December 2021 update of\u00a0the Makefile Tools extension for Visual Studio Code\u00a0is here, bringing you support for problem matchers (to easily view errors and warnings in the editor), the ability to generate a compile_commands.json file for your project, and a bunch of other enhancements and bug fixes! To find out more about all the enhancements, [&hellip;]<\/p>\n","protected":false},"author":27203,"featured_media":29857,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[274,3908,3909,3910,271,3904,3905,3906,3907,3911,276],"class_list":["post-29854","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus","tag-c-extension","tag-compilation-database","tag-compile-commands","tag-compile_commands-json","tag-cpp","tag-make","tag-makefile","tag-makefile-tools","tag-problem-matcher","tag-vs-code","tag-vscode"],"acf":[],"blog_post_summary":"<p>The December 2021 update of\u00a0the Makefile Tools extension for Visual Studio Code\u00a0is here, bringing you support for problem matchers (to easily view errors and warnings in the editor), the ability to generate a compile_commands.json file for your project, and a bunch of other enhancements and bug fixes! To find out more about all the enhancements, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/29854","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=29854"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/29854\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/29857"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=29854"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=29854"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=29854"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}