Skip to content

Latest commit

 

History

History
41 lines (30 loc) · 1.12 KB

compiler-warning-c4959.md

File metadata and controls

41 lines (30 loc) · 1.12 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Compiler Warning C4959
Compiler Warning C4959
11/04/2016
C4959
C4959
3a128f3e-4d8a-4565-ba1a-5d32fdeb5982

Compiler Warning C4959

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

Remarks

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

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

The /clr:safe compiler option is deprecated in Visual Studio 2015 and unsupported in Visual Studio 2017.

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

Example

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
}