How can I compile some parts of C++/CLI code as Native and some part as Managed?

StackOverflow https://stackoverflow.com/questions/2995673

  •  24-10-2019
  •  | 
  •  

سؤال

I am calling LoadTypeLib for loading unmanaged type libraries in C++/CLI. I need to compile some code areas as managed and some code areas as unmanaged (native) and form a mixed mode class library as executable.

What part do I need to be managed and unmanaged (native) to compile as managed and native respectively?

هل كانت مفيدة؟

المحلول

#pragma managed

Prefer using #pragma managed with push and on/off, then pop, #pragma unmanaged is actually quite useless.

نصائح أخرى

Don't use #pragma managed - it's considered "evil" and may cause problems with DLL init/shutdown.

I would recommend explicitly compiling some files as managed (/clr), and some as native (without /clr). You can also have two pre-compiled headers - one for managed, one for native.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top