Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Warning C4959

cannot define unmanaged struct 'type' in /clr:safe because accessing its members yields unverifiable code

Accessing a member of an unmanaged type will produce an unverifiable (peverify.exe) image.

For more information, see Pure and Verifiable Code (C++/CLI).

This warning is issued as an error and can be disabled with the warning pragma or the /wd compiler option.

The following sample generates C4959:

// C4959.cpp
// compile with: /clr:safe

// Uncomment the following line to resolve.
// #pragma warning( disable : 4959 )
struct X {
   int data;
};

int main() {
   X x;
   x.data = 10;   // C4959
}

Community Additions

ADD
Show:
© 2015 Microsoft