visual studio .net ide:
Hi, Happy new year everybody. Sorry for crossposting, but I don't know which is the best : vc.ide_general or vsnet.ide ? I am working on a project with VC++ 2003 and it compile & link well, but I have a strange problem. I have a singleton class with the following static function: myclass & myclass::GetInstance() { static myclass m; return m; } This class is compiled as a static lib and used by an other project "main" in the same solution. My problem is that the static keyword seems to be ignored by the compiler. Each time I call GetInstance(), a new object is created (the constructor of m is called). It used to work, and the only change I found which seems to be responsible of that are the project dependencies. Before, I used to manually add the static lib myclass.lib in the link tab of my project. Now I removed this manual reference and checked the project myclass in the project dependencies of my "main" project, and I have this problem. I don't understand what is wrong. Thanks for your help. -- Aurélien REGAT-BARREL
Hi, I found the problem, after 2 long days of research :-/ I moved one class (.h + .cpp) from a project of the solution to an other one, but I forgot to remove the old one. So I had the same class twice, in 2 static libs. I don't know why the linker didn't complained of duplicated symbols. Instead of that it seems it mixed the 2 classes, I don't know how, but it managed to create stack/heap corruption and I don't understand too why it corrupted my static object by making it being considered as an automatic object. I guess the project dependencies influence is due to the directory search order. Hard pain for a stupid mistake. -- Aurélien REGAT-BARREL
Don't see what you're looking for? Try a search.
|