Date: Thu, 3 Aug 2000 17:39:31 -0400 (Eastern Daylight Time) From: Chris BeHanna <behanna@zbzoom.net> To: hackers@freebsd.org Subject: Re: malloc to arrays? Message-ID: <Pine.WNT.4.21.0008031738190.365-100000@armani.yourfit.com> In-Reply-To: <200008032124.BAA04719@aaz.links.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 4 Aug 2000, Aleksandr A.Babaylov wrote:
> Chris Costello writes:
> > On Wednesday, August 02, 2000, Mike Smith wrote:
> > > tcpcash_addr = (typeof(tcpcash_addr))
> > > malloc(sizeof(*tcpcash_addr) *
> > > TCPCASH_ROWSIZE *
> > > TCPCASH_COOLSIZE);
> > Just as a note on coding style, this will only hide warnings
> > caused by not including <stdlib.h>. malloc(3) returns void * and
> > does not need to be cast.
> So there is an error in gcc in base system?
> See:
>
> 1cicuta~/w/ra-tools(6)>cat tmp.c
> #include <stdlib.h>
>
> int main()
> { int *(i[100]);
>
> i = malloc(400);
> }
> 0cicuta~/w/ra-tools(7)>cc tmp.c
> tmp.c: In function `main':
> tmp.c:6: incompatible types in assignment
> 1cicuta~/w/ra-tools(8)>uname -a
> FreeBSD cicuta.babolo.ru 4.0-STABLE FreeBSD 4.0-STABLE #0: Fri Jun 9 14:01:52 MSD 2000 babolo@cicuta.babolo.ru:/tmp/obj/usr/src/sys/cicuta i386
> 0cicuta~/w/ra-tools(9)>
There's no error at all. You've declared i to be an array of 100
pointers to int, but then you've tried to assign a pointer to that
array, and gcc quite naturally complains.
--
Chris BeHanna
Software Engineer (at yourfit.com)
behanna@zbzoom.net
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.WNT.4.21.0008031738190.365-100000>
