Kompilatorvarning C4959

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

Anmärkningar

Åtkomst till en medlem av en ohanterad typ ger en icke-verifierad (peverify.exe) bild.

Mer information finns i Ren och verifierbar kod (C++/CLI).

Alternativet /clr:safe compiler är inaktuellt i Visual Studio 2015 och stöds inte i Visual Studio 2017.

Den här varningen utfärdas som ett fel och kan inaktiveras med varnings pragma eller kompilatoralternativet /wd .

Example

I följande exempel genereras 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
}