{"id":144,"date":"2017-06-25T00:35:24","date_gmt":"2017-06-25T00:35:24","guid":{"rendered":"http:\/\/cppdepend.com\/wordpress\/?p=144"},"modified":"2023-05-31T16:40:22","modified_gmt":"2023-05-31T16:40:22","slug":"spotting-cpp11-cpp14-cpp17-features-in-winobjc-study","status":"publish","type":"post","link":"https:\/\/cppdepend.com\/blog\/spotting-cpp11-cpp14-cpp17-features-in-winobjc-study\/","title":{"rendered":"Spotting C++11\/C++14\/C++17 Features in WinObjC: A Study"},"content":{"rendered":"<p>In a <a href=\"http:\/\/www.codergears.com\/Blog\/?p=1566\">previous post<\/a> we talked about the clang-modernize tool to detect where you can use some new C++11 features to modernize your C++ source code. But how can we easily detect where the new C++ features are used in a project?<\/p>\n<p>Facebook and Google use C++11 extensively\u00a0in their source code. Folly from Facebook as we discovered in a <a href=\"http:\/\/www.codergears.com\/Blog\/?p=431\">previous post<\/a> use almost all of the C++11 features and I was curious to know if Microsoft also use the new \u00a0C++11 standards in their open sourced code.<!--more--><span id=\"more-1998\"><\/span><\/p>\n<p>The Microsoft open source projects can\u00a0be found in their <a href=\"https:\/\/github.com\/Microsoft\">GitHub <\/a>repository. Some of them are only forks from other projects that they have adapted to their needs like LLVM, Clang and OpenCV and others are developed by them. Let\u2019s take a look in one of their projects and discover if the C++11 is utilized.\u00a0The best choice could be their latest open sourced C\/C++ project:<a href=\"https:\/\/github.com\/Microsoft\/WinObjC\">WinObjc<\/a>.<\/p>\n<p>Windows Bridge for iOS (also referred to as WinObjC) is a Microsoft open source project that provides an Objective-C development environment for Visual Studio\/Windows. In addition, WinObjC provides support for iOS API compatibility.<\/p>\n<p>A first method we can employ solution to check where C++11 was\u00a0used is to explore each source file which could take hours or maybe days depending on the size of the project. Another solution is to use Clang.<\/p>\n<p><strong>Clang and its powerful diagnostic engine to the rescue.<\/strong><\/p>\n<p>The clang team aims to provide error messages that are as clear and expressive\u00a0as possible. They try to make it as user-friendly as they can for a command line compiler. To do this,\u00a0clang pinpoints exactly what is wrong in the code. This is done through a diagnostics engine which processes the error information into a user-friendly message.<\/p>\n<p>Clang emits many kind of diagnostics and for our needs\u00a0the more interested\u00a0ones have a description like this:\u00a0\u201cXXX\u00a0incompatible with C++98\u2033<\/p>\n<p><strong>But how can we get the Clang Diagnostics for a Visual Studio solution?<\/strong><\/p>\n<p>The first alternative is to compile your projects using Clang, however it\u2019s not an easy task. Indeed, you have to modify your build process to use Clang instead of the microsoft compiler.<\/p>\n<p>The second alternative is to analyze your visual studio projects using\u00a0<a href=\"http:\/\/www.cppdepend.com\/\">CppDepend<\/a>\u00a0which uses Clang as front end parser, and report all its diagnostics. CppDepend is\u00a0<a href=\"http:\/\/ossperks.com\/\">free for the open source community<\/a>.<\/p>\n<p>And here\u2019s the result of all clang diagnostics for the WinObjc solution<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/win1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2001\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/win1.png\" alt=\"win1\" width=\"461\" height=\"528\" \/><\/a><\/p>\n<p>But in our case we need only the diagnostics of kind \u201cincompatible with C++98\u2033. You can easily filter the previous request to get only these diagnostics:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/win2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2002\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/win2.png\" alt=\"win2\" width=\"460\" height=\"537\" \/><\/a><\/p>\n<p>As we can observe the nullptr and auto features are used in many places in the source code, but unlike Facebook and Google projects the C++11 features are not widely used. Also,\u00a0when exploring the C++ source files of WinObjC, we can remark that they use the C++\/CX extensions\u00a0more.<\/p>\n<p><strong>Summary<\/strong>:<\/p>\n<p>Sometimes it&#8217;s interesting to know if a c++ project uses the new standards and where they\u00a0are used. Clang is a powerful tool for gathering this info.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a previous post we talked about the clang-modernize tool to detect where you can use some new C++11 features to modernize your C++ source code. But how can we easily detect where the new C++ features are used in a project? Facebook and Google use C++11 extensively\u00a0in their source code. Folly from Facebook as &hellip; <a href=\"https:\/\/cppdepend.com\/blog\/spotting-cpp11-cpp14-cpp17-features-in-winobjc-study\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Spotting C++11\/C++14\/C++17 Features in WinObjC: A Study&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[12,35,36,3,22],"class_list":["post-144","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-c11","tag-c14","tag-c17","tag-cplusplus","tag-winobjc"],"_links":{"self":[{"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/posts\/144","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/comments?post=144"}],"version-history":[{"count":6,"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/posts\/144\/revisions"}],"predecessor-version":[{"id":1500,"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/posts\/144\/revisions\/1500"}],"wp:attachment":[{"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/media?parent=144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/categories?post=144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/tags?post=144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}