Generates a report with a debug message and sends the report to three possible destinations (debug version only).
int _CrtDbgReport ( int reportType, const char *filename, int linenumber, const char *moduleName, const char *format, ... );
reportType
_CRT_WARN
, _CRT_ERROR
, or _CRT_ASSERT
.
*filename
NULL
.
linenumber
NULL
.
*moduleName
*format
_CrtDbgReport can send the debug report to these different destinations:
Two configuration functions, _CrtSetReportMode and _CrtSetReportFile, specify the destination(s) for each report type. These functions allow separate control for eachreport type's destination(s). For example, you can send a reportType
of _CRT_WARN to only the debug monitor, while sending a reportType
of_CRT_ASSERT to a debug message window and a user-defined report file.
_CrtDbgReport creates the user message for the debug report by substituting the argument[n] arguments into the format
string, using the same rules defined by printf. _CrtDbgReport then generates the debug report and determines the destination(s), based on the current report modes and file defined for reportType
. When the report is sent to a debug message window, the filename
, lineNumber
, and moduleName
are included in the information that displays in the window.
The following table lists available choices for the report mode(s) and file, plus the resulting behavior of _CrtDbgReport. These options are defined as bit-flags in CRTDBG.H.
Report mode | Report file | _CrtDbgReport behavior |
---|---|---|
_CRTDBG_ MODE_FILE |
int (file handle) | Writes a message to a user-supplied file descriptor, using the INtime write() API, and does not verify validity of the file handle; the application opens the report file and passes a valid file descriptor. |
_CRTDBG_ MODE_FILE |
_CRTDBG_ FILE_STDERR |
Writes a message to stderr. |
_CRTDBG_ MODE_FILE |
_CRTDBG_ FILE_STDOUT |
Writes a message to stdout. |
The report can be sent to one, two, or three destinations, or to no destination at all. For more information about specifying the report mode or modes and report file, see _CrtSetReportMode and _CrtSetReportFile. For more information about using the debug macros and reporting functions, see Using Macros for Verification and Reporting.
If your application needs more flexibility than that provided by _CrtDbgReport, you can write your own reporting function and hook it into the C run-time library reporting mechanism by using _CrtSetReportHook.
0
(zero)
-1
The _ASSERT[E] and _RPT, _RPTF debug macros call _CrtDbgReport to generate their debug report and start the debugger, provided that "just-in-time" (JIT) debugging is enabled.
Note: If the user clicks the Abort button in the Debug Message window, _CrtDbgReport immediately aborts and does not return a value.
Versions | Defined in | Include | Link to |
---|---|---|---|
INtime 3.13 | intime/rt/include/crtdbg.h | crtdbg.h | clib.lib |