Re: function pointers
- From: "cr88192" <cr88192@xxxxxxxxxxx>
- Date: Mon, 7 Jan 2008 14:44:48 +1000
"Ark Khasin" <akhasin@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:vNhgj.832$xA6.11@xxxxxxxxxxx
"Tom????????????????????????????????" wrote:
The only redudant checks I use in my programs are asserts.May I suggest that's a very dubious practice.
Debug build crashes predictably; Release build (with NDEBUG #define'd)
either crashes unpredictably or wanders away mysteriously.
Use asserts for debugging and never for user input. On the API level, your
user can be another programmer.
- Ark
what I do depends a lot on context.
usually, I try to detect most cases that are dubious, but still workable,
and try to handle the situation gracefully (very often, this is in finding
an alternate way to do something, or returning some sort of error status).
in some cases, if the problem is particularly serious, very often I will
print some debugging messages and initiate a controlled crash.
even though windows doesn't much like the crashes (when they are unexpected
and I am not running a debugger, causing both crashes and annoying popup
messages), they are good in that they make it a lot easier to crash the
program just where I want it to be (sort of like a semi-permanent
breakpoint), which makes it a lot easier to try to recreate the problem in a
debugger, and then have it crash somewhere where I can easily examine the
state and can try to figure out what has gone wrong.
there are different ways to invoke crashes, but the one I typically use is
this:
*(int *)-1=-1;
on linux, this option works better though, since linux crashes give a
general debugger-usable core dump (sadly absent on windows...).
well, it works at least.
.
- Follow-Ups:
- Re: function pointers
- From: Michal Nazarewicz
- Re: function pointers
- From: Ian Collins
- Re: function pointers
- References:
- function pointers
- From: hifrnds007
- Re: function pointers
- From: Tomás Ó hÉilidhe
- Re: function pointers
- From: Michal Nazarewicz
- Re: function pointers
- From: Tomás Ó hÉilidhe
- Re: function pointers
- From: Ark Khasin
- function pointers
- Prev by Date: Re: RotateLeft, what does it do?
- Next by Date: Re: function pointers
- Previous by thread: Re: function pointers
- Next by thread: Re: function pointers
- Index(es):
Relevant Pages
|