Feedback: Making /Zc:inline default for debug/release configs in “14”

Eric Battalio

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++’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 of Visual Studio 2013 Update 2 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 /Zc:inline specified, the compiler requires that translation units that use inline data or inline functions must also include the definitions for the data or functions.

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:


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:

     xfunc.obj : error LNK2019: unresolved external symbol “public: void __thiscall x::xfunc1(void)”
         (?xfunc1@x@@QAEXXZ) referenced in function _main

     x.exe : fatal error LNK1120: 1 unresolved externals

There are two recommended ways to fix this problem.

  1. Remove the ‘inline’ keyword from the declaration of function ‘xfunc’.
  2. Move the definition of function ‘xfunc’ into the header file “x.h”.

We would love you folks to try this feature out in latest CTPs (found here) and help us gauge the impact, hopefully positive this feature will have by enabling it by default for VS2014.



Discussion is closed.

Feedback usabilla icon