编译器错误 C3833
“type”:pointer_type 的目标类型无效
interior_ptr 或 pin_ptr 声明不正确。
下面的示例生成 C3833:
// C3833.cpp
// compile with: /clr
ref class MyClass {
public:
int data;
MyClass() : data(35) {}
};
int main() {
interior_ptr<MyClass> p; // C3833
// OK
MyClass ^ h_MyClass = gcnew MyClass;
interior_ptr<int> i = &(h_MyClass->data);
System::Console::WriteLine(*i);
}
下面的示例生成 C3833:
// C3833b.cpp
// compile with: /clr /c
ref class G {
public:
int i;
};
int main() {
G ^ pG = gcnew G;
pin_ptr<G> ppG = &pG; // C3833 can't pin a whole object
// OK
pin_ptr<int> ppG2 = &pG->i;
*ppG2 = 54;
int * pi = ppG2;
System::Console::WriteLine(*pi);
System::Console::WriteLine(*ppG2);
*pi = 55;
System::Console::WriteLine(*pi);
System::Console::WriteLine(*ppG2);
*ppG2 = 56;
System::Console::WriteLine(*pi);
System::Console::WriteLine(*ppG2);
}
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈