C ++ / CLI相当于C#关键字检查 [英] C++/CLI equivalent of C# checked keyword

查看:202
本文介绍了C ++ / CLI相当于C#关键字检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有在C ++ / CLI托管代码抛出算术溢出异常的方法吗? C#有选中的关键字,也是全球项目标志启用这些,但我能找到的既不是C ++ / CLI ...

Is there a way for managed code in C++/CLI to throw exceptions on arithmetic overflow? C# has the checked keyword and also global project flags to enable these, but I can find neither in C++/CLI...

我的情况是,我封装C ++库在.NET。有时候,C ++本地代码溢出。我/正在考虑把一些敏感的计算,以现有的C ++ / CLI的包装,但也许这是不可能的?

My situation is that I am wrapping C++ libs in .NET. Sometimes the C++ native code overflows. I was/am considering moving some sensitive calculations to existing C++/CLI wrapper, but perhaps this is not possible?

推荐答案

链接重复毫无意义,C ++ / CLI如下C ++约定。 C ++有用于检测算术溢出没有内置的机制。

The linked duplicate make no sense, C++/CLI follows C++ conventions. C++ has no built-in mechanism for detecting arithmetic overflow.

使用的检查的和的选中的关键字,原本计划对于C ++ / CLI的未来扩展。 ECMA-372 是当前语言标准,并提出了在本扩展附录F.2.1。然而,这从来没有发生过,是非常不可能被永远执行。

Using the checked and unchecked keywords was originally planned for future extensions of C++/CLI. Ecma-372 is the current language standard and proposes this extension in appendix F.2.1. This however never happened and is very unlikely to be ever implemented.

您会因此必须实现溢出检查自己。你会发现在这个问题。

You'll thus have to implement overflow checking yourself. You'll find some guidance in this question.

这篇关于C ++ / CLI相当于C#关键字检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆