PRB: /MD Causes C4273 Warning When Replacing _matherr (112337)
The information in this article applies to:
- The C Run-Time (CRT), when used with:
- Microsoft Visual C++, 32-bit Editions 1.0
- Microsoft Visual C++, 32-bit Editions 2.0
This article was previously published under Q112337 SYMPTOMS
Attempting to replace the default _matherr function with a user-defined
version and then linking with the C run-time dynamic-linked library (DLL)
causes the compiler to issue the following warning:
warning C4273: '_matherr' : inconsistent dll linkage. dllexport
assumed.
Running the resultant executable causes the default _matherr to be used
rather than the user-defined version.
CAUSE
The compiler issues the C4273 warning because of the way the _matherr
function is prototyped in the MATH.H header file. _matherr has the
following prototype:
_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.
The C4273 warning is generated because the compiler has detected a
redefinition of _matherr after already seeing a prototype that specifies
that _matherr is being imported.
RESOLUTION
It is not possible to replace the default version of _matherr when using
the dynamically linked version of the C run-time library.
The README.WRI file supplied with Visual C++, 32-bit Edition, version 1.0,
gives the following information:
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.
Modification Type: | Major | Last Reviewed: | 11/18/2003 |
---|
Keywords: | kbCRT kbprb KB112337 |
---|
|