In my current assignment there is an application where they have mixed managed (I have never worked with managed C++ before) and native C++ code. I tried to introduce the usage of smart pointers and as soon as I added a static one... BAM! The code didn't even make it to main before crashing. After some surfing I found out that the reason for that is that in managed C++ the crt startup code is bypassed.
The solution given on the net was to add __DllMainCRTStartup@12 in linker Force Symbol References. Even though it feels a bit strange to call Dll... it seems to do the trick of getting all statics properly initialized. What I've failed to find though is how to force a call to the cleanup on exit. Has anybody here some insight?
If anyone is curious I've attached a minimalistic 2010 Express project that demonstrate the issue. Comment/uncomment the define in NativeLib.cpp, run and then just Close the form to see the leak report (or not depending on the define).
Edit: I forgot to mention that the project settings are copied from the full one so it might be something that look peculiar for the posted one.