O'Reilly logo

Extending MFC Applications with the .NET Framework by Nishant Sivakumar, Tom Archer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mixed-Mode Programming Issues

As with any new development environment, there are some caveats that you should be aware of when mixing managed and unmanaged code. In this part, we examine a few of the most common problems encountered by those new to mixed-mode programming:

  • Avoiding inadvertent #define side-effects

  • Allocating reference objects in MFC debug builds

  • Using string literals and converting strings

Avoiding Inadvertent #define Side Effects

One of the first issues you're sure to run into is the problem caused when you attempt to use a function, operator, or type that has been #define'd to a different value than you expect. One example of that is in attempting to use the MessageBox::Show method:

 using namespace System; ... // Display a message ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required