Article ID: 120919
Article Last Modified on 10/24/2003
// FILE NOWARN.H
#pragma warning(disable:4201)
#pragma warning(disable:4214)
//FILE MYMOD.C
#include "NOWARN.H"
#include <windows.h>
void main(void) {}
For further examples, see AFX.H, located in the MFC\INCLUDE subdirectory of
your Visual C++ version 2.0 installation. AFX.H uses #pragma warning to
disable specific level 4 warnings when compiling MFC applications.
struct A;
void x(A*);
struct A
{
virtual void f() = 0;
A() { x(this); }
};
struct B : A
{
void f() { }
};
void x(A*p) { p->f(); }
void main()
{
B aB; // calls B::B calls A::A calls
} // x calls A::f (pure virtual function)
Because such errors cannot be caught at compile time, the __purecall
function is called, generating the following run-time error:
If an application (such as a device driver) must be compiled without
using the standard run-time libraries (compiler option /Zl or linker
option /NODEFAULTLIB), but requires virtual function calls, you will get
an "undefined symbol" linker error on __purecall. You can work around
this error in one of two ways:
int __purecall( void )
{
/* insert your own error reporting code here */
return 0;
}
If __purecall is redefined in exactly this way, no run time error is
generated if the user calls a pure virtual function. The custom
__purecall function should contain appropriate error checking and
recovery code, (for example, calling _exit or printing a fatal error
message) as noted in the sample.
Additional query words: 2.00 9.00
Keywords: KB120919