_set_error_mode modifies __error_mode to determine a non-default location where the C runtime writes an error message for an error that will, possibly, end the program.
int _set_error_mode( int modeval );
Macro | Required Header | Compatibility |
_set_error_mode | <stdlib.h> | ANSI, Win 95, Win NT |
Libraries
LIBCD.LIB | Single thread static library, debug version |
LIBC.LIB | Single thread static library, retail version |
LIBCMTD.LIB | Multithread static library, debug version |
LIBCMT.LIB | Multithread static library, retail version |
MSVCRTD.LIB | Import library for MSVCRTD.DLL, debug version |
MSVCRT.LIB | Import library for MSVCRT.DLL, retail version |
Return Value
Returns old setting or -1 if an error occurs.
Parameter
modeval
destination of error messages
Remarks
Control the error output sink by setting the value of __error_mode. Explicit controls are to direct output to standard error or to use the MessageBox API.
The modeval parameter can be set to one of the follow:
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_errror_mode will display the failed statement in the dialog box and give you the option of selecting Ignore, which allows you to continue executing the program.
Example
#include <stdlib.h>
#include <assert.h>
main()
{
_set_error_mode(_OUT_TO_MSGBOX);
assert(!"this is a test");
}