Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!utcsri!greg From: greg@utcsri.UUCP Newsgroups: comp.lang.c,news.software.b Subject: Re: passing NULL to functions Message-ID: <4724@utcsri.UUCP> Date: Sun, 3-May-87 18:42:12 EDT Article-I.D.: utcsri.4724 Posted: Sun May 3 18:42:12 1987 Date-Received: Mon, 4-May-87 01:47:07 EDT References: <150@sds.UUCP> <1129@ius2.cs.cmu.edu> <5804@brl-smoke.ARPA> Reply-To: greg@utcsri.UUCP (Gregory Smith) Organization: CSRI, University of Toronto Lines: 22 Xref: utgpu comp.lang.c:1972 news.software.b:565 Summary: In article <5804@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: >In article <1129@ius2.cs.cmu.edu> edw@ius2.cs.cmu.edu (Eddie Wyatt) writes: >>#define alloc(type) ((type *) malloc(sizeof(type))) > >Yup, although you might want one more set of () around the first `type'. > But then alloc(int) -> (((int) *) malloc (sizeof(int))) is a syntax error. The problem you seem to be addressing is that (type *) is not always a cast to pointer to type: e.g. int (*)() means pointer to func returning int, but ( int (*)() * ) means you get a syntax error. There is no cure for this; it is a result of C's bass-ackward type syntax. That definition of alloc simply cannot be used with types containing array or function notation ( although you can alwaytypedef them to avoid having ()'s and [n]'s in the 'alloc()' ). -- ---------------------------------------------------------------------- Greg Smith University of Toronto UUCP: ..utzoo!utcsri!greg Have vAX, will hack...