This documentation is archived and is not being maintained.

Debugging Preparation: Win32 Projects

This topic applies to:


Visual Basic



Web Developer


Topic does not applyTopic does not applyTopic appliesTopic does not apply


Topic does not apply

Topic does not apply

Topic applies

Topic does not apply

Pro and Team

Topic does not apply

Topic does not apply

Topic applies

Topic does not apply

Table legend:

Topic applies


Topic does not apply

Does not apply

Topic applies but command hidden by default

Command or commands hidden by default.

Win32 applications are traditional Windows programs written in C or C++. Debugging this type of application in Visual Studio is straightforward.

Win32 applications include MFC applications and ATL projects. They use Windows APIs and may use MFC or ATL, but they do not use the common language runtime (CLR). They can, however, call managed code that uses the CLR.

The following procedure explains how to debug a Win32 project from within Visual Studio. Another way to debug a Win32 application is to start the application outside of Visual Studio and attach to it. For more information, see Attaching to Running Processes.

To debug a C or C++ Win32 application

  1. Open the project in Visual Studio.

  2. On the Debug menu, choose Start.

  3. Debug using the techniques discussed in Debugger Roadmap.

    When you create a Windows Application project with the wizard, Visual Studio automatically creates required settings for the Debug and Release configurations. If necessary, you can change those settings. For more information, see How to: Set Debug and Release Configurations.

To manually set a Debug configuration

  1. On the View menu, click Property Pages.

  2. Click the Configuration Properties node to open it if it is not already open.

  3. Select General, and set the value of the Output row to Debug.

  4. Open the C/C++ node, and select General.

    In the Debug row you specify the type of debugging information to be generated by the compiler. Values you might choose include Program Database (/Zi) or Program Database for Edit & Continue (/ZI).

  5. Select Optimization, and in the Optimization row, select Disabled (/0d) from the drop-down list.

    Optimized code is harder to debug, since the generated instructions do not correspond directly to your source code. If you find your program has a bug that appears only in optimized code, you can turn this setting on, but remember that code shown in the Disassembly window is generated from optimized source that may not match what you see in your source windows. Features such as stepping are likely to show breakpoints and execution point incorrectly.

  6. Open the Linker node, and select Debugging. In the first Generate row, select Yes (/DEBUG) from the drop-down list. Always set this when you are debugging.

    For more information, see Project Settings for a C++ Debug Configuration.