Re: Ike Naar
- From: Richard Heathfield <rjh@xxxxxxxxxxxxxxx>
- Date: Mon, 09 Feb 2009 10:44:48 +0000
nick_keighley_nospam@xxxxxxxxxxx said:
<snip>
[...] I believe (meaning I can' remember where I read it)
that this is problematic
assert (p);
that it needs to be replaced with
assert (p != 0);
to be safe
Yes, that's required in C90 because assert requires an integer
expression (specifically, a value of type int). In C99, however,
assert(p) is safe because the requirement was slackened, so that
only a scalar expression is needed - and pointer values count as
scalar expressions. I wouldn't do it that way myself, partly
because C99 isn't portable enough yet but mostly because I prefer
to use relational expressions in cases where the object is not
specifically intended "booleanly", so to speak. Thus, I'm okay with
if(is_printer_ready) but not okay with if(balance). I recognise
that this is just a style thing, of course (in C99).
<snip>
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
.
- Follow-Ups:
- Re: Ike Naar
- From: Nate Eldredge
- Re: Ike Naar
- References:
- Re: (part1a) Han from China teached you C
- From: Ike Naar
- Re: Ike Naar
- From: Han from China
- Re: Ike Naar
- From: Malcolm McLean
- Re: Ike Naar
- From: Stephen Sprunk
- Re: Ike Naar
- From: pete
- Re: Ike Naar
- From: Ben Bacarisse
- Re: Ike Naar
- From: Keith Thompson
- Re: Ike Naar
- From: Richard
- Re: Ike Naar
- From: nick_keighley_nospam
- Re: (part1a) Han from China teached you C
- Prev by Date: Re: c to c++
- Next by Date: Re: Ike Naar
- Previous by thread: Re: Ike Naar
- Next by thread: Re: Ike Naar
- Index(es):
Relevant Pages
|