分类: C/C++
2008-08-26 20:32:13
_invalid_parameter_handler _set_invalid_parameter_handler( _invalid_parameter_handler pNew ); |
void _invalid_parameter( const wchar_t * expression, const wchar_t * function, const wchar_t * file, unsigned int line, uintptr_t pReserved ); |
// crt_set_invalid_parameter_handler.c // compile with: /Zi /MTd #include #include #include void myInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved) { wprintf(L"Invalid parameter detected in function %s." L" File: %s Line: %d\n", function, file, line); wprintf(L"Expression: %s\n", expression); } int main( ) { char* formatString; _invalid_parameter_handler oldHandler, newHandler; newHandler = myInvalidParameterHandler; oldHandler = _set_invalid_parameter_handler(newHandler); // Disable the message box for assertions. _CrtSetReportMode(_CRT_ASSERT, 0); // Call printf_s with invalid parameters. formatString = NULL; printf(formatString); } |
Invalid parameter detected in function printf. File: f:\dd\vctools\crt_bld\self_
|