MSVC Incremental Linker Woes

Started by
2 comments, last by Shannon Barber 22 years, 9 months ago
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)
			{
			//BOOM!

			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
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Advertisement
You are not alone there. I think that''t why shift-f7 maps to full rebuild 8)
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.
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:
m_listObserver.push_back(pObserver);
... instead of calling both insert() and end()? Trying to be independent of the container type?

This topic is closed to new replies.

Advertisement