This topic is now archived and is closed to further replies.

Shannon Barber

MSVC Incremental Linker Woes

Recommended Posts

Are there any rules or guidelines to follow that tell you when you need to perform a full compile? Am I the only one that runs into odd program behavior and spurious exceptions from incrementally compiled/linked code? (Full compiles seem to clear up alot of problems for me) Does this mean I have crap code & ram stompage? Or is the MSVC incremental linker bugged? (SP5) When I ran just a moment ago this code exploded:
		typedef std::list<TObserver*> tyListObserver;
		tyListObserver m_listObserver;

		void AddObserver(TObserver* pObserver)

			m_listObserver.insert(m_listObserver.end(), pObserver);
Now, unless the MS STL list is fubar (which I guess it could be), that code can''t fail! It doesn''t even matter if pObserver is null! And m_listObserver is created on the stack! After a full compile it runs flawlessly, in both debug & release builds! frustrating... Maybe it''s all the templates I use. Magmai Kai Holmlor - The disgruntled & disillusioned

Share this post

Link to post
Share on other sites
You may have some bugged code where you actually use this function, I have found in my experience anyway that in a full build some memory leak problems will not show up because there is no debug information available. I am pretty sure that the VC incremental linker is not bugged (I could be wrong of course) because it is such a fundamental element of C++.

I''ve had code that I could swear is flawless only to find out later I missed an obvious problem.

Share this post

Link to post
Share on other sites
My (uninformed) guess is this:

Templates and their linkage is a bit different to a normal functions. Normal functions can just be compiled to an object file, and all that any other object file needs to know is how many bytes to stick on the stack when calling that function. So normal functions (including member functions) can easily be compiled separately of each other, with it being trivial for the compiler to detect when everything else needs changing (eg. when the function prototype changes).

However, templates add a spanner to the works, in that there is technically a different compilation required for each type parameter you give to them. So you have one set of compilation for the syntax of the template itself, and one set for checking each individual instantiation.

So my guess is that, with an imperfect compiler, you probably need to do a full recompile whenever you do much with templates Although, I can''t say I''ve had any problems recently. I am just suggesting that sometimes, the compiler fails to guess all the complex template dependencies and doesn''t recompile everything it should.

Oh... and why not just do:
... instead of calling both insert() and end()? Trying to be independent of the container type?

Share this post

Link to post
Share on other sites