Error del compilador C3883
Actualización: noviembre 2007
Mensaje de error
'variable' : se debe inicializar un miembro de datos estático initonly
'var' : an initonly static data member must be initialized
No se inicializó correctamente una variable marcada con initonly.
El ejemplo siguiente genera el error C3883:
// C3883.cpp
// compile with: /clr
ref struct Y1 {
initonly
static int staticConst1; // C3883
};
El ejemplo siguiente muestra una posible solución:
// C3883b.cpp
// compile with: /clr /c
ref struct Y1 {
initonly
static int staticConst2 = 0;
};
El ejemplo siguiente 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;
}
};