This documentation is archived and is not being maintained.

Compiler Warning (level 3) C4398

'variable' : per-process global object might not work correctly with multiple appdomains; consider using __declspec(appdomain)

A virtual function with __clrcall calling convention in a native type causes the creation of a per application domain vtable. Such a variable may not correct correctly when used in multiple application domains.

You can resolve this warning by compiling with /clr:pure, which makes global variables per appdomain by default, or by explicitly marking the variable __declspec(appdomain).

For more information, see appdomain and Application Domains and Visual C++.

The following sample generates C4398.

// C4398.cpp
// compile with: /clr /W3 /c
struct S {
   virtual void f( System::String ^ );   // String^ parameter makes function __clrcall

S glob_s;   // C4398
__declspec(appdomain) S glob_s2;   // OK