Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

_set_error_mode

Modifies __error_mode to determine a nondefault location where the C run time writes an error message for an error that will possibly end the program.

int _set_error_mode(
   int modeval 
);

Parameter

modeval
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 standard error or use the MessageBox API.

The modeval parameter can be set to one of the following:

Parameter Description
_OUT_TO_DEFAULT Error sink is determined by __app_type.
_OUT_TO_STDERR Error sink is standard error.
_OUT_TO_MSGBOX Error sink is a message box.
_REPORT_ERRMODE Report the current __error_mode value.

When used with an assert, _set_error_mode will display the failed statement in the dialog box and give you the option of clicking Ignore, which allows you to continue executing the program.

Requirements

Routine Required header Compatibility
_set_error_mode <stdlib.h> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP

Libraries

All versions of the C run-time libraries.

Example

// crt_set_error_mode.c
#include <stdlib.h>
#include <assert.h>

int main()
{
   _set_error_mode(_OUT_TO_STDERR);
   assert(2+2==5);
}

Sample Output

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