Export (0) Print
Expand All
div
Expand Minimize
3 out of 3 rated this helpful - Rate this topic

_CrtSetReportMode

Specifies the destination or destinations for a specific report type generated by _CrtDbgReport and any macros that call _CrtDbgReport, such as _ASSERT, ASSERTE, _RPT, and _RPTF (debug version only).

int _CrtSetReportMode( 
   int reportType,
   int reportMode 
);

Parameters

reportType
Report type: _CRT_WARN, _CRT_ERROR, _CRT_ASSERT.
reportMode
New report mode or modes for reportType.

Return Value

Upon successful completion, _CrtSetReportMode returns the previous report mode or modes for the report type specified in reportType. If an error occurs, the report mode or modes for reportType are not modified and _CrtSetReportMode returns –1.

Remarks

_CrtSetReportMode specifies the output destination for _CrtDbgReport. Because the macros _ASSERT, _ASSERTE, _RPT, and _RPTF call _CrtDbgReport, _CrtSetReportMode specifies the output destination of text specified with those macros.

When _DEBUG is not defined, calls to _CrtSetReportMode are removed during preprocessing.

If you do not call _CrtSetReportMode to define the output destination of messages, the following defaults are in effect:

  • Assertion failures and errors are directed to a debug message window.
  • Warnings from Windows applications are sent to the debugger's output window.
  • Warnings from console applications are not displayed.

The following table lists the report types defined in CRTDBG.H.

Report type Description
_CRT_WARN Warnings, messages, and information that does not need immediate attention.
_CRT_ERROR Errors, unrecoverable problems, and issues that require immediate attention.
_CRT_ASSERT Assertion failures (asserted expressions that evaluate to FALSE).

The _CrtSetReportMode function assigns the new report mode specified in reportMode to the report type specified in reportType and returns the previously defined report mode for reportType. The following table lists the available choices for reportMode and the resulting behavior of _CrtDbgReport. These options are defined as bit-flags in CRTDBG.H.

Report mode _CrtDbgReport behavior
_CRTDBG_MODE_DEBUG Writes the message to the debugger's output window.
_CRTDBG_MODE_FILE Writes the message to a user-supplied file handle. _CrtSetReportFile should be called to define the specific file or stream to use as the destination.
_CRTDBG_MODE_WNDW Creates a message box to display the message along with the Abort, Retry, and Ignore buttons.
_CRTDBG_REPORT_MODE Returns reportMode for the specified reportType:

1   _CRTDBG_MODE_FILE

2   _CRTDBG_MODE_DEBUG

4   _CRTDBG_MODE_WNDW

Each report type can be reported using one, two, or three modes, or no mode at all. Therefore, it is possible to have more than one destination defined for a single report type. For example, the following code fragment causes assertion failures to be sent to both a debug message window and to stderr:

_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_WNDW );
_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );

In addition, the reporting mode or modes for each report type can be separately controlled. For example, it is possible to specify that a reportType of _CRT_WARN be sent to an output debug string, while _CRT_ASSERT be displayed using a debug message window and sent to stderr, as previously illustrated.

Requirements

Routine Required header Compatibility
_CrtSetReportMode <crtdbg.h> Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.

Libraries

Debug versions of C run-time libraries only.

Example

For a sample of how to use _CrtSetReportMode, see report.

See Also

Debug Functions | Run-Time Routines and .NET Framework Equivalents

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.