I have an issue with incremental linking in that when I change some code it sometimes does a full link. I have narrowed the code down to a specific piece and was wondering if anyone knows why.
I am using Visual Studio 2012 (it exhibits the same behavior in 2015). I have created a blank solution with 2 projects in it (a lib and an exe). I have setup incremental linking to work properly (importing library outputs as well).
The exe simply has main call into 'UpdateFrame' which is listed below.
This is all the code from the library project itself.
struct TypeId
{
unsigned char myTypeId;
// Comment out this line and it links incrementally
TypeId() : myTypeId(0) {}
};
template<class Type>
struct TypeRegistrationHelper
{
static TypeId ourTypeId;
};
template<class Type> TypeId TypeRegistrationHelper<Type>::ourTypeId;
// Uncomment this line and it links incrementally
//template struct TypeRegistrationHelper<float>;
void UpdateFrame()
{
// Commenting/uncommenting this line causes a full link to happen
// unless you have changed 1 of the 2 lines listed above. Then it links
// incrementally as expected when changing this line.
TypeRegistrationHelper<float>::ourTypeId;
}
The problem comes up that if I comment out the line in UpdateFrame, it causes a full link to happen (unless I have modified one of the two lines that are commented in code -- then everything works fine)
I've enabled verbose output for incremental linking and this is the reason it lists as performing a full relink:
LINK : directives changed; performing full link
This is the MSDN page regarding this particular error (note it says its for VC 6.0)
And this is the only information it contains
A directive was added or deleted since the last incremental linking session. A full link was required in order to recreate the incremental status (.ILK) file.
Here is my main function (in the application project obviously)
#include "Updater.h"
int main()
{
UpdateFrame();
return 0;
}