Compartir a través de


Error del compilador C3883

'member': se debe inicializar un miembro de datos estático initonly

Observaciones

No se inicializó correctamente una variable marcada con initonly.

Example

En el siguiente ejemplo se genera el código de error C3883:

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

En el ejemplo siguiente se muestra una posible resolución:

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

En el ejemplo siguiente se muestra cómo inicializar en un constructor estático:

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

   static Y1() {
      staticConst1 = 0;
   }
};