Skip to content

Latest commit

 

History

History
84 lines (61 loc) · 2.75 KB

set-error-mode.md

File metadata and controls

84 lines (61 loc) · 2.75 KB
descriptiontitlems.dateapi_nameapi_locationapi_typetopic_typef1_keywordshelpviewer_keywordsms.assetid
Learn more about: _set_error_mode
_set_error_mode
11/04/2016
_set_error_mode
msvcrt.dll
msvcr80.dll
msvcr90.dll
msvcr100.dll
msvcr100_clr0400.dll
msvcr110.dll
msvcr110_clr0400.dll
msvcr120.dll
msvcr120_clr0400.dll
ucrtbase.dll
api-ms-win-crt-runtime-l1-1-0.dll
DLLExport
apiref
set_error_mode
_set_error_mode
_set_error_mode function
set_error_mode function
f0807be5-73d1-4a32-a701-3c9bdd139c5c

_set_error_mode

Modifies __error_mode to determine a non-default location where the C runtime writes an error message for an error that might end the program.

Important

This API cannot be used in applications that execute in the Windows Runtime. For more information, see CRT functions not supported in Universal Windows Platform apps.

Syntax

int_set_error_mode( intmode_val );

Parameters

mode_val
Destination of error messages.

Return value

Returns the old setting or -1 if an error occurs.

Remarks

Controls the error output sink by setting the value of __error_mode. For example, you can direct output to a standard error or use the MessageBox API.

The mode_val parameter can be set to one of the following values.

ValueDescription
_OUT_TO_DEFAULTError sink is determined by __app_type.
_OUT_TO_STDERRError sink is a standard error.
_OUT_TO_MSGBOXError sink is a message box.
_REPORT_ERRMODEReport the current __error_mode value.

If a value is passed in other than the listed ones, the invalid parameter handler is invoked, as described in Parameter validation. If execution is allowed to continue, _set_error_mode sets errno to EINVAL and returns -1.

When it's used with an assert, _set_error_mode displays the statement that failed in the dialog box, and gives you the option of choosing the Ignore button, so that you can continue to run the program.

Requirements

RoutineRequired header
_set_error_mode<stdlib.h>

Example

// crt_set_error_mode.c// compile with: /c#include<stdlib.h>#include<assert.h>intmain() { _set_error_mode(_OUT_TO_STDERR); assert(2+2==5); }
Assertion failed: 2+2==5, file crt_set_error_mode.c, line 8 This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. 

See also

assert Macro, _assert, _wassert

close