How do people handle warning C4793: 'some_function' : function compiled as native?

梦想的初衷 提交于 2019-12-03 09:58:45

I think what you want is this:

#pragma unmanaged
#include <cv.h>
#pragma managed
// managed code wrapping unmanaged opencv functions

A C++/CLI project can contain both managed and unmanaged parts, and the compiler takes care of marshalling data between the 2 for you. The managed entry points will be callable from normal .NET apps (like C# and the rest) and will use garbage collection, and they'll call unmanaged functions to do the heavy lifting.

fmuecke

I think you should suppress the warning. The MSDN doc explicitly states that the managed/unmanaged pragmas should not be used before include statements.

#pragma warning(disable: 4793) // methods are compiled as native (clr warning)
#include <cv.h>
#pragma warning(pop)

If you cannot change existing code files, you can get rid of the warning by disabling CLR support for the specific file that shows warning 4793. Of course, this only works if this file does not make any use of CLR features.

To disable CLR support for a specific file, locate it in Solution Explorer, right-click and open its Property Pages. Set Common Language RunTime Support to No Common Language RunTime Support. Don't forget to do this for All Configurations and All Platforms.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!