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;
}
};
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for