NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Compiler Warning (level 4) C4669

'cast' : unsafe conversion: 'class' has managed members

The cast class contains managed extensions for C++. The compiler completes the cast by performing a bitwise copy of one pointer to the other, but provides no other checking. To resolve the warning, do not cast classes containing members with managed extensions.

The following sample generates C4669:

#using "mscorlib.dll"

__gc struct A {
   int i;
   Object   * pObj;   // remove the managed member to resolve the warning
};

__gc struct B {
   int j;
};

void main() {
   A *a = new A;
   
   B *b = reinterpret_cast<B*>(a);   // C4669
}