{"id":294,"date":"2018-01-29T16:43:26","date_gmt":"2018-01-29T16:43:26","guid":{"rendered":"http:\/\/cppdepend.com\/blog\/?p=294"},"modified":"2023-05-31T16:13:43","modified_gmt":"2023-05-31T16:13:43","slug":"cpp11-cpp14-cpp17-features-in-winobjc-case-study","status":"publish","type":"post","link":"https:\/\/cppdepend.com\/blog\/cpp11-cpp14-cpp17-features-in-winobjc-case-study\/","title":{"rendered":"C++11\/C++14\/C++17 Features in WinObjC: A Case Study"},"content":{"rendered":"<p>In a\u00a0<a href=\"https:\/\/cppdepend.com\/blog\/?p=262\">previous post<\/a>\u00a0we talked about the clang-tidy tool to detect where you can use some new C++11\/C++14\/C++17 features to modernize your C++ source code. \u00a0But how we can easily detect where the new C++ features are used in a project?<\/p>\n<p>Facebook and Google use intensively C++11 in their source code. Folly from Facebook as we discovered in a\u00a0<a href=\"https:\/\/cppdepend.com\/blog\/?p=20\">previos post<\/a>\u00a0use almost all 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 could be found in their\u00a0<a href=\"https:\/\/github.com\/Microsoft\">GitHub\u00a0<\/a>repository, some of them are only forks from other projects to adapt them 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 adopted and the 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 solution to check where C++11 were used 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 as clear and expressive error messages as possible. They try to make it as user friendly as they can for a command line compiler. To do so,\u00a0clang should pinpoint 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 has a description like this:\u00a0\u201cXXX\u00a0incompatible with C++98\u2033<\/p>\n<p><strong>But how we can 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. And when exploring the C++ source files of WinObjC, we can remark that they use more the C++\/CX extensions.<\/p>\n<p><strong>Summary<\/strong>:<\/p>\n<p>The new C++ standards become more used these days due to the big work of the C++ community. Many new features are very easy to use and it&#8217;s recommended to modernize your C++ code to makes it easy to read and maintain.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a\u00a0previous post\u00a0we talked about the clang-tidy tool to detect where you can use some new C++11\/C++14\/C++17 features to modernize your C++ source code. \u00a0But how we can easily detect where the new C++ features are used in a project? Facebook and Google use intensively C++11 in their source code. Folly from Facebook as we &hellip; <a href=\"https:\/\/cppdepend.com\/blog\/cpp11-cpp14-cpp17-features-in-winobjc-case-study\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;C++11\/C++14\/C++17 Features in WinObjC: A Case 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":[7,12,35,36,22],"class_list":["post-294","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-c","tag-c11","tag-c14","tag-c17","tag-winobjc"],"_links":{"self":[{"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/posts\/294","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=294"}],"version-history":[{"count":2,"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/posts\/294\/revisions"}],"predecessor-version":[{"id":1490,"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/posts\/294\/revisions\/1490"}],"wp:attachment":[{"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/media?parent=294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/categories?post=294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/tags?post=294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}