Category Archives: C++

Programming Challenges: 110208 Yahtzee

I completed the Yahtzee problem today, after a couple of days effort. I first double checked my previous 2004 solution’s scoring function, there were a few gems in there that I had to reprove, like how the full house was … Continue reading

Posted in C++, Programming | Tagged | Leave a comment

GetTextMetricsW causing memory corruption

I have been converting our ANSI product to UNICODE, and today during testing I was getting “Run-Time Check Failure #2 – Stack around the variable ‘tm’ was corrupted.” error messages. Turned out it was this code: TEXTMETRICW tm; GetTextMetricsW( hDC, … Continue reading

Posted in C++, Programming | Leave a comment

SafeArrayTypeMismatchException

We extended our legacy C++ DCOM application last week, and when the developer wrote the C#.Net end to call the new method, we were getting the error: System.Runtime.InteropServices.SafeArrayTypeMismatchException The developer that had added the method stated it work, and pointed … Continue reading

Posted in .Net, C#, C++, Programming | 2 Comments

Evils of typedefs and legacy code

Our legacy C++ codebase once was a C codebase.  Way back then, there was no standard boolean type.  So in the wisdom of the day a type was declared typedef int tBool; The major problem with tBool’s is that over … Continue reading

Posted in C++, Programming | Leave a comment

#pragma pack()

I have just spent the last hour bashing my head, trying to workout why some new C++ code (to my project) was crashing. I was constructing one class, and it was building some worker classes and crashing in the std::vector … Continue reading

Posted in C++, Programming | 1 Comment