Compiler Warning C4368
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Compiler Warning C4368.
cannot define 'member' as a member of managed 'type': mixed types are not supported
You cannot embed a native data member in a CLR type.
You can, however, declare a pointer to a native type and control its lifetime in the constructor and destructor and finalizer of your managed class. For more information see Destructors and finalizers.
This warning is always issued as an error. Use the warning pragma to disable C4368.
The following sample generates C4368.
// C4368.cpp
// compile with: /clr /c
struct N {};
ref struct O {};
ref struct R {
R() : m_p( new N ) {}
~R() { delete m_p; }
property N prop; // C4368
int i[10]; // C4368
property O ^ prop2; // OK
N * m_p; // OK
};
Show: