INtime SDK Help
_CrtDbgReport
INtime SDK v7.1 > About INtime > Other system libraries > Heaps and memory pools > Using the Debug Heap > Writing your own debug hook functions > _CrtDbgReport

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, ... 
);

Parameters

reportType
Valid values include: _CRT_WARN, _CRT_ERROR, or _CRT_ASSERT.
*filename
Pointer to source filename where the assert/report occurred or NULL.
linenumber
Line number in source file where the assert/report occurred or NULL.
*moduleName
Pointer to the module name (.rta or .rsl) where assert/report occurred.
*format
Pointer to the format-control string used to create the user message.

Remarks

_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.

Return Values

0 (zero)
Success.
-1
Failure.

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.

Requirements

Versions Defined in Include Link to
INtime 3.13 intime/rt/include/crtdbg.h crtdbg.h clib.lib
   
See Also