Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.lang.c Subject: Re: Casting call Message-ID: <2203@sun.uucp> Date: Wed, 22-May-85 04:16:30 EDT Article-I.D.: sun.2203 Posted: Wed May 22 04:16:30 1985 Date-Received: Fri, 24-May-85 03:57:39 EDT References: <10784@brl-tgr.ARPA> Organization: Sun Microsystems, Inc. Lines: 13 > What you really want is a "typeof" operator: > > #define FREE(ptr) { free((char *) ptr); ptr = (typeof ptr) NULL; } You don't need it. If we were using ANSI C, we wouldn't need to cast null pointers at all, except in calls to "execl" and the like, as long as we declared the types of arguments to routines; the compiler would know that a given routine expected a "char *" and would coerce a 0 passed to the routine into a "(char *)0". In this case, the compiler does know that you're assigning 0 to a pointer of a particular type, and that it should cast the 0 into a "(typeof ptr)0". Guy Harris