delorie.com/archives/browse.cgi | search |
From: | Edward Hill <ha AT nochance DOT com> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: A Structured Problem ? |
Date: | Wed, 21 Jul 1999 16:04:51 +0100 |
Organization: | GEC-Marconi |
Lines: | 25 |
Message-ID: | <3795E193.4AAD506E@nochance.com> |
References: | <7mv0te$gq2$1 AT news6 DOT svr DOT pol DOT co DOT uk> <Pine DOT SUN DOT 3 DOT 96 DOT 990719090429 DOT 29235A-100000 AT silver DOT cs DOT umanitoba DOT ca> <7n09p0$9db$1 AT news5 DOT svr DOT pol DOT co DOT uk> <7n1c6l$14s$1 AT taliesin DOT netcom DOT net DOT uk> <379450DC DOT E0B363B5 AT nochance DOT com> <3795CD8F DOT 191A8C0E AT americasm01 DOT nt DOT com> |
NNTP-Posting-Host: | pc02372.gmsws.gecm.com |
Mime-Version: | 1.0 |
X-Mailer: | Mozilla 4.51 [en] (Win95; I) |
X-Accept-Language: | en |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
"Campbell, Rolf [SKY:1U32:EXCH]" wrote: > > Edward Hill wrote: > > > It's good practice not to cast, malloc doesn't require a cast and a cast > > can sometimes mask errors. > > How can casting mask an error? And why doesn't malloc need a cast? Under ANSI/ISO Standard C, casting the return from malloc is not necessary, and in fact modern practice discourages it, since it can camouflage important warnings which would otherwise be generated if malloc() happened not to be declared correctly; An example would be not having #include <stdlib.h> if malloc isn't cast it would give you a compiler warning telling you your assigning a pointer from an integer, the default return value. If you cast the return from malloc you will silence this warning. Ed
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |