断言 [英] assert

查看:63
本文介绍了断言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是assert()仅用于调试吗?

我是否有可能在Borland

c ++ 32编译器中看到使用assert()(所以断言不是仅调试)

解决方案
朱塞佩< GI ****** @ giuseppe.wwwew>写道:

是assert()仅用于调试吗?


是的。或者让它以另一种方式陈述。主张应仅在

的代码是在发展,当你释放你的产品/方案,
$ B $比乙要与NODEBUG规定编制,使用,以便所有断言会是
消失。

我是否有可能在Borland
c ++ 32编译器中看到assert()的使用(因此断言不仅用于调试) )?




有可能,但不能从这个事实中得出结论,无论如何这都是正确的用法。 Borland接缝已发布调试版

或其产品。


-

Z(Zo **** ****** @ daimlerchrysler.com)

LISP值得学习深刻的启蒙经验

当你终于得到它时你将拥有;这段经历会让你在剩下的日子里成为更好的程序员。 - Eric S. Raymond


>断言()仅用于调试吗?


工具的用途由使用它的人决定。这是

可能是有人在那里采用断言()用于驱动钉子和

使用铅笔谋杀的人。
是它可能的,我所看到的使用在Borland C ++编译器32的(因此断言不是调试只)?



是它您可能已经看过Borland

c ++ 32编译器的源代码?我不知道。如果你有,无论是否
使用assert()都没有说明assert()是否仅用于调试

。仅仅因为代码是一个生产版本并不意味着

没有错误。但是,我不确定我是否愿意乘坐一架飞机或太空船,其飞行控制软件使用断言(),

或住在附近控制软件使用它的核反应堆。


Gordon L. Burditt


GI ****** @ giuseppe.wwwe W(朱塞佩)写道:

#只或不能断言()用于调试

#我是否有可能在Borland

#c ++ 32编译器中看到assert()的使用(因此断言不仅用于调试)?


调试最困难,理解问题一旦代码

即将投入生产,人们不断将其锤击到极限

谁不尊重你的测试套件。


因此,为了速度,生产代码正是在你需要禁用所有检查的时候,断言,数组边界和其他

范围,堆栈弹出pr这样可以确保最大程度的损坏,并且最不可能修复它。


-

Derk Gwen < a rel =nofollowhref =http://derkgwen.250free.com/html/index.htmltarget =_ blank> http://derkgwen.250free.com/html/index.html

那么......这会让伯大尼成为黑人吗?


is assert() for debug only or not?
Is it possible that I have seen the use of assert() in the Borland
c++ 32 compiler (so assert is not for debug only)?

解决方案

Giuseppe <gi******@giuseppe.wwwew> wrote:

is assert() for debug only or not?
Yes. Or let it state in another way. Assert should only be used while
the code is in development, than when you release your product/program,
you want to compile with NODEBUG defined, so that all assertions will be
gone.
Is it possible that I have seen the use of assert() in the Borland
c++ 32 compiler (so assert is not for debug only)?



It is possible, though one cannot conclude from that fact that this is
the correct usage anyway. Borland seams to have released a debug-version
or their product.

--
Z (Zo**********@daimlerchrysler.com)
"LISP is worth learning for the profound enlightenment experience
you will have when you finally get it; that experience will make you
a better programmer for the rest of your days." -- Eric S. Raymond


>is assert() for debug only or not?

The purpose of a tool is determined by the person using it. It is
possible that someone out there uses assert() for driving nails and
uses pencils for murdering people.

Is it possible that I have seen the use of assert() in the Borland
c++ 32 compiler (so assert is not for debug only)?



Is it possible that you have seen the source code of the Borland
c++ 32 compiler? I don''t know. If you have, whether or not it
uses assert() says little about whether or not assert() is for debug
only. Just because code is a production release does not mean it
is bug-free. However, I''m not sure I''d be comfortable riding in
an airplane or spacecraft whose flight-control software used assert(),
or living near a nuclear reactor whose control software used it.

Gordon L. Burditt


gi******@giuseppe.wwwew (Giuseppe) wrote:
# is assert() for debug only or not?
# Is it possible that I have seen the use of assert() in the Borland
# c++ 32 compiler (so assert is not for debug only)?

The most diffult to debug, to understand problems occur in once the code
is in production, where it is constantly hammerred to its limits by people
who have no respect for your test suite.

Therefore in the interest of speed, production code is precisely when
you need to disable all checking, assertions, array bounds and other
ranges, stacks popped properly, etc. This ensures the maximum damage and
the least possibility of fixing it.

--
Derk Gwen http://derkgwen.250free.com/html/index.html
So....that would make Bethany part black?


这篇关于断言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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