Conditional Compilation and the Build Environment You should conditionally compile the debugging code in your driver by testing the DBG preprocessor constant.
The value of DBG depends on the build environment window you use to build your driver:
If you create your driver by running the Build utility in a checked build environment, DBG will equal 1.
If you create your driver by running the Build utility from a free build environment, DBG will equal 0 (or will be undefined if neither wdm.h nor ntddk.h is included).
The debugging routines ASSERT, ASSERTMSG, KdBreakPoint, KdBreakPointWithStatus, KdPrint, and KdPrintEx are actually macros that are conditionally defined depending on the value of DBG. If it is 0, these macros are no-ops. Therefore, these macros are active only in the checked build of a driver. Note All debugging routines beginning with the letters "Kd" have no effect in a free build of a driver, except for KdRefreshDebuggerNotPresent.
For more information about the build environments that allow you to create free and checked builds of a driver, see Setting Up the Build Environment.