{"id":293,"date":"2014-09-26T13:00:00","date_gmt":"2014-09-26T13:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2014\/09\/26\/feedback-making-zcinline-default-for-debugrelease-configs-in-14\/"},"modified":"2021-07-29T14:31:34","modified_gmt":"2021-07-29T14:31:34","slug":"feedback-making-zcinline-default-for-debugrelease-configs-in-14","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/feedback-making-zcinline-default-for-debugrelease-configs-in-14\/","title":{"rendered":"Feedback: Making \/Zc:inline default for debug\/release configs in \u201c14\u201d"},"content":{"rendered":"<p>Given our strong focus on improving build times of our toolset as a part of the Visual Studio 14 preview we will be changing a few defaults for Visual C++&#8217;s debug and release configuration. These changes include making <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dn642448.aspx\">\/Zc:inline<\/a> (remove unreferenced COMDAT) the default for debug and release configurations. <strong>\/Zc:inline<\/strong> was introduced as a part of <strong>Visual Studio 2013 Update 2<\/strong> and provides a significant speed up (double digit (%) link throughput improvements for non-debug (\/Od) builds) along with reducing size of static libraries compiled drastically. However with <strong>\/Zc:inline<\/strong> specified, the compiler requires that translation units that use inline data or inline functions must also include the definitions for the data or functions.<\/p>\n<p>This can possibly result in a breaking change for non-conformant code (with the C++11 standard). Turning on this feature could mean in some cases you see an unresolved external symbol error as shown below but the workaround is very simple:<\/p>\n<p style=\"background: white\"><span style=\"color: #424242;font-family: Segoe UI;font-size: 9pt\">&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/09\/2577.Zcinline.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/09\/2577.Zcinline.png\" alt=\"Image 2577 Zcinline\" width=\"597\" height=\"288\" class=\"alignnone size-full wp-image-28522\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/09\/2577.Zcinline.png 597w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/09\/2577.Zcinline-300x145.png 300w\" sizes=\"(max-width: 597px) 100vw, 597px\" \/><\/a><\/span><\/p>\n<p style=\"background: white\">If you are using VS2013 RTM, this sample program will compile (cl \/O2 x.cpp xfunc.cpp) and link successfully. However, if you compile and link with VS2013 Update 2 CTP2 and above with \/Zc:inline enabled (cl \/O2 \/Zc:inline x.cpp xfunc.cpp), the sample will choke and produce the following error message:<\/p>\n<p style=\"background: white\"><span style=\"color: #0070c0\">&nbsp;&nbsp;&nbsp;&nbsp; xfunc.obj : error LNK2019: unresolved external symbol &#8220;public: void __thiscall x::xfunc1(void)&#8221; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(?xfunc1@x@@QAEXXZ) referenced in function _main <\/span><\/p>\n<p style=\"background: white\"><span style=\"color: #0070c0\">&nbsp;&nbsp;&nbsp;&nbsp; x.exe : fatal error LNK1120: 1 unresolved externals <\/span><\/p>\n<p style=\"background: white\">There are <strong>two recommended ways<\/strong> to fix this problem.<\/p>\n<ol>\n<li>\n<div style=\"background: white\">Remove the &#8216;inline&#8217; keyword from the declaration of function &#8216;xfunc&#8217;.<\/div>\n<\/li>\n<li>\n<div style=\"background: white\">Move the definition of function &#8216;xfunc&#8217; into the header file &#8220;x.h&#8221;.<\/div>\n<\/li>\n<\/ol>\n<p>We would love you folks to try this feature out in latest CTPs (found <a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkId=509824\">here<\/a>) and help us gauge the impact, hopefully positive this feature will have by enabling it by default for VS2014.<\/p>\n<p>Thanks!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Given our strong focus on improving build times of our toolset as a part of the Visual Studio 14 preview we will be changing a few defaults for Visual C++&#8217;s debug and release configuration. These changes include making \/Zc:inline (remove unreferenced COMDAT) the default for debug and release configurations. \/Zc:inline was introduced as a part [&hellip;]<\/p>\n","protected":false},"author":264,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[65],"class_list":["post-293","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus","tag-compiler"],"acf":[],"blog_post_summary":"<p>Given our strong focus on improving build times of our toolset as a part of the Visual Studio 14 preview we will be changing a few defaults for Visual C++&#8217;s debug and release configuration. These changes include making \/Zc:inline (remove unreferenced COMDAT) the default for debug and release configurations. \/Zc:inline was introduced as a part [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/293","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\/264"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=293"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/293\/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=293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}