From owner-freebsd-hackers Thu Aug 3 14:39:35 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from mail.yourfit.com (28.wxfr1.xdsl.nauticom.net [209.195.150.61]) by hub.freebsd.org (Postfix) with ESMTP id 94D2137B85B for ; Thu, 3 Aug 2000 14:39:32 -0700 (PDT) (envelope-from behanna@zbzoom.net) Received: from armani.yourfit.com (armani.yourfit.com [192.168.1.120]) by mail.yourfit.com (8.9.3/8.9.3) with ESMTP id RAA05958 for ; Thu, 3 Aug 2000 17:39:31 -0400 Date: Thu, 3 Aug 2000 17:39:31 -0400 (Eastern Daylight Time) From: Chris BeHanna Reply-To: Chris BeHanna To: hackers@freebsd.org Subject: Re: malloc to arrays? In-Reply-To: <200008032124.BAA04719@aaz.links.ru> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 . 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 > > 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