Article ID: 112337
Article Last Modified on 11/18/2003
_CRTIMP int __cdecl _matherr(struct _exception *);When code is being compiled to be used with the C run-time DLL, _CRTIMP is defined to be the following:
__declspec(dllimport)When code is being compiled to be used with one of the statically linked C run-time libraries, _CRTIMP is defined to be nothing.
Using _matherr with CRTDLL.DLL If you use the dynamically linked version of the C run-time library (CRTDLL.DLL), you cannot replace the default _matherr routine with a user-defined version. You can only install a custom _matherr routine if you use one of the statically linked C run-time libraries.CRTDLL.DLL is the name of the C Run-time DLL that is supplied with Windows NT. The C Run-time DLL supplied with version 1.0 of Visual C++, 32-bit Edition, is called MSVCRT10.DLL and the name of the C Run-time DLL supplied with version 2.0 of Visual C++, 32-bit Edition is MSVCRT20.DLL. The limitation of not being able to replace _matherr pertains only to using MSVCRT*.DLL.
/* Compile options needed: /MD
*/
#include <math.h>
#include <string.h>
#include <stdio.h>
void main()
{
// Do a math operation that causes an error
printf( "log( -2.0 ) = %e\n", log( -2.0 ) );
}
int _matherr( struct _exception *except )
{
/* Handle _DOMAIN errors for log */
if( except->type == _DOMAIN )
{
if( strcmp( except->name, "log" ) == 0 )
{
except->retval = log( -(except->arg1) );
printf( "Special: using absolute value: %s: _DOMAIN "
"error\n", except->name );
return 1;
}
}
else
{
printf( "Normal: " );
return 0; /* Else use the default actions */
}
return 0;
}
112297 INFO: User Defined CRT Function Causes Unresolved External
Additional query words: _matherrl
Keywords: kbcrt kbprb KB112337