Expand Minimize
This topic has not yet been rated - Rate this topic

Compiler Error C3883

'var' : an initonly static data member must be initialized

A variable marked with initonly was not initialized correctly.

The following sample generates C3883:

// C3883.cpp
// compile with: /clr
ref struct Y1 {
   initonly
   static int staticConst1;   // C3883
};

The following sample demonstrates a possible resolution:

// C3883b.cpp
// compile with: /clr /c
ref struct Y1 {
   initonly
   static int staticConst2 = 0;
};

The following sample shows how to initialize in a static constructor:

// C3883c.cpp
// compile with: /clr /LD
ref struct Y1 {
   initonly
   static int staticConst1;

   static Y1() {
      staticConst1 = 0;
   }
};
Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.