简体   繁体   中英

OpenCV warning: "function compiled as native"

I created a Windows Form Project using Visual Studio 2010 and ported some of my codes from an older console project that uses OpenCV. I got the following message when I compile:

opencv\\include\\opencv\\cxoperations.hpp(81): warning C4793: 'anonymous namespace'::CV_XADD' : function compiled as native :

After some digging, it appears to be an issue with CLR support setting. I've seen a few posts that talked about the same issue but my question here would be more general:

What's this deal with "native" and "clr"? What's the difference in the various levels of clr support? I don't think I have found a page that can concisely tell me about the concept before being overloaded with a bunch of other details.

Thanks.

Short answer : It sounds like you are compiling your project as C++/CLI. If you want ordinary unmanaged C++, use the C++ "Win32 Project" template in Visual Studio instead of the "Windows Forms Application" one.

Longer answer : A C++/CLI programs can contain two kinds of types:

  • Native - These are ordinary C++ types.
  • CLR - These are are special types ("ref classes") that are really managed .NET types.

The magic of C++/CLI is that you can mix ordinary native C++ types with .NET types in one program. You can call from the native types to CLR types and back, and C++/CLI generates the necessary interop code.

Normally, you'd only worry about this if you have existing .NET code and native code and you need to get them working together. If you don't have that scenario, you'd just use ordinary native C++.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM