नोट
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप साइन इन करने या निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
'function' : uses pinning pointers but unwind semantics are not enabled. Consider using /EHa
Remarks
To unpin an object on the managed heap pointed to by a pinning pointer declared in a block scope, the compiler simulates the behavior of destructors of local classes, "pretending" the pinning pointer has a destructor that nullifies the pointer. To enable a call to a destructor after throwing an exception, you must enable object unwinding, which you can do by using /EHsc.
You can also manually unpin the object and ignore the warning.
Example
The following example generates C4823.
// C4823.cpp
// compile with: /clr /W3 /EHa-
using namespace System;
ref struct G {
int m;
};
void f(G ^ pG) {
try {
pin_ptr<int> p = &pG->m;
// manually unpin, ignore warning
// p = nullptr;
throw gcnew Exception;
}
catch(Exception ^) {}
} // C4823 warning
int main() {
f( gcnew G );
}