CL /Bd

This option enables a debugging mode.


The option is /Bd only.


The option is acted on by CL.EXE in advance of executing compiler modules, and is also passed to the compiler modules.

Actions by CL

With /Bd enabled, each execution in the build is preceded by a description written to standard error. Each execution is typically described as a command, showing the module or program that will be executed, together with its command line. In some cases there is first a listing of environment variables that CL has set or of lines that CL has written into a command file.

To enable this debugging mode but suppress the executions, use /Bz (instead).

The /Bd and /Bz options both disable the minimal rebuild facility, without warning. (This is not done by formally cancelling whatever /Gm option enabled the minimal rebuild, and the front-end C++ compiler continues to get -Gm on its command line.)

The debugging mode enabled by /Bd and /Bz also affects the compiler’s handling of exceptions. The top-level exception handler in CL.EXE ordinarily reports an access violation as an internal compiler error (D2030). However, once the debugging mode is active, such exceptions are left as unhandled. Something similar applies to the handling of exceptions while CL calls the _InvokeCompilerPass@12 function of any compiler module that is implemented as a DLL.

Actions by Compiler Modules

The /Bd option carries to the front-end and back-end compiler modules, which also modify their handling of exceptions. The usual practice with the sort of exception that originates from a coding error such as dereferencing a null pointer is to report the CPU exception as an internal compiler error (C1001), perhaps disguised as an unrecoverable error (C1903) or even as a something called a bad provider interaction (C1904). The attendant mystery and frustration (the latter an unsurprising consequence of the former) are reduced by the /Bd option, which lets the exception leave the compiler as unhandled. In practice these days, the exception is then picked up by Dr Watson, which offers to send details to Microsoft over the Internet.

For the front-end compiler modules (C1 and C1XX, for C and C++ respectively), the /Bd option affects the handling of the __compileBreak keyword, so that its presence in source code causes a break to the debugger.