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.
Last edited by S_M_A; February 11th, 2013 at 04:41 PM.
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.