编译器错误 C3890
“var”:不能采用 literal 数据成员的地址
回收了垃圾的堆上存在文本数据成员。 回收了垃圾的堆上的对象是可以移动的,因此,获取地址没有用。
以下示例生成 C3890:
// C3890.cpp
// compile with: /clr
ref struct Y1 {
literal int staticConst = 9;
};
int main() {
int p = &Y1::staticConst; // C3890
int p2 = Y1::staticConst; // OK
}
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈