“member”:initonly 静态数据成员必须初始化
注解
标有 initonly 的变量未正确初始化。
Example
以下示例生成 C3883:
// C3883.cpp
// compile with: /clr
ref struct Y1 {
initonly
static int staticConst1; // C3883
};
以下示例演示了可能的解决方法:
// C3883b.cpp
// compile with: /clr /c
ref struct Y1 {
initonly
static int staticConst2 = 0;
};
以下示例演示如何在静态构造函数中初始化:
// C3883c.cpp
// compile with: /clr /LD
ref struct Y1 {
initonly
static int staticConst1;
static Y1() {
staticConst1 = 0;
}
};