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 C4368

Error Message

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 (see Destructors and Finalizers in Visual C++ for more information).

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

Community Additions

© 2015 Microsoft