Code Optimization

The Windows Driver Kit (WDK) provides build environments to produce the following builds:

  • Checked (debug) builds to use during development.

  • Free (release) builds that generate the final versions of your code.

By default, the WDK build environment enables code optimization in a free build and disables code optimizations in a checked build.

The WDK uses the MSC_OPTIMIZATION macro to disable code optimizations in a checked build. To disable code optimizations in a free build, add the following macro to your Sources file:

MSC_OPTIMIZATION=/Od /Oi

It is rare that you would disable code optimizations in a free build. However, this macro is useful if you need to disable code optimizations in just one part of a large project.

You can also use the following platform-specific macros in your Sources file to override the default WDK build environment setting for MSC_OPTIMIZATION:

For example, you can specify the following macro in your Sources file to disable code optimization on 386 platforms:

386_OPTIMIZATION=/Od

Note  If you plan to do source-level debugging, use a checked build, which disables code optimization. Debugging optimized code can be extremely difficult.

 

 

Send comments about this topic to Microsoft

Build date: 5/3/2011