Compiler Error C3831
'member': 'class' cannot have a pinned data member or a member function returning a pinning pointer
pin_ptr (C++/CLI) was used incorrectly.
Example
The following sample generates C3831:
// C3831a.cpp
// compile with: /clr
ref class Y
{
public:
int i;
};
ref class X
{
pin_ptr<int> mbr_Y; // C3831
int^ mbr_Y2; // OK
};
int main() {
Y y;
pin_ptr<int> p = &y.i;
}
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