OpenCV 警告:“函数编译为本机”

发布于 2025-01-05 09:22:17 字数 390 浏览 0 评论 0原文

我使用 Visual Studio 2010 创建了一个 Windows 窗体项目,并从使用 OpenCV 的旧控制台项目移植了一些代码。编译时收到以下消息:

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

经过一番挖掘,这似乎是 CLR 支持设置的问题。我看过一些讨论相同问题的帖子,但我在这里的问题更笼统:

“native”和“clr”是做什么用的?不同级别的 clr 支持有什么区别?我认为我没有找到一个页面可以在被一堆其他细节超载之前简洁地告诉我这个概念。

谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独夜无伴 2025-01-12 09:22:17

简短回答
听起来您正在将项目编译为 C++/CLI。如果您需要普通的非托管 C++,请使用 Visual Studio 中的 C++“Win32 项目”模板,而不是“Windows 窗体应用程序”模板。

更长的答案
C++/CLI 程序可以包含两种类型:

  • Native - 这些是普通的 C++ 类型。
  • CLR - 这些是特殊类型(“引用类”),它们是真正托管的 .NET 类型。

C++/CLI 的神奇之处在于,您可以在一个程序中将普通的本机 C++ 类型与 .NET 类型混合在一起。您可以从本机类型调用 CLR 类型并返回,C++/CLI 会生成必要的互操作代码。

通常,只有当您拥有现有的 .NET 代码和本机代码并且需要让它们协同工作时,您才需要担心这一点。如果没有这种情况,您只需使用普通的本机 C++。

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++.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文