Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!watnot!watdaisy!dvadura From: dvadura@watdaisy.UUCP Newsgroups: comp.lang.c Subject: Re: Casting NULL? Message-ID: <8087@watdaisy.UUCP> Date: Fri, 23-Jan-87 09:27:31 EST Article-I.D.: watdaisy.8087 Posted: Fri Jan 23 09:27:31 1987 Date-Received: Sat, 24-Jan-87 04:50:07 EST References: <3179@brl-adm.ARPA> Reply-To: dvadura@watdaisy.UUCP (Dennis Vadura) Organization: Computer Science Dept., University of Waterloo Lines: 22 In article <3179@brl-adm.ARPA> Peter Steele - Acadia writes: >I have a question about pointers: I just recently read >a C text where whenever NULL was passed as a parameter >it was casted to the proper type. > >He claimed that >this is required because pointers to different types of objects >may not be the same size. I don't know how common it is, but a simple solution is to define: #define NIL(a) (a *)NULL; when you need to pass a null pointer to an int or a char then say NIL( int ) or NIL( char ) this works for structs and other objects as well. typedef foo { .... } BAR; then NIL( BAR ) is a NULL pointer of type BAR.