Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cwjcc!abvax!ivan!aep From: aep@ivan (Alex E. Pensky) Newsgroups: comp.lang.c Subject: Re: More NULL questions Message-ID: <903@abvax.UUCP> Date: 9 Oct 89 16:28:02 GMT References: <5950001@hpldola.HP.COM> <443@shodha.dec.com> Sender: news@abvax.UUCP Reply-To: aep@ivan.UUCP (Alex E. Pensky) Organization: Allen-Bradley Company, Inc.; Industrial Computer Division; Highland Hts. OH Lines: 27 In article <443@shodha.dec.com> devine@shodha.dec.com (Bob Devine) writes: >In article <5950001@hpldola.HP.COM>, jg@hpldola.HP.COM (Joe Gilray) writes: >> 2) Is there danger using >> int a, b; >> my_func(a, NULL, b); >> as apposed to >> my_func(a, (struct thing *)NULL, b); > > You are in trouble if you do not use function prototypes >if your system's pointer representation is not the same size >as an int. Moreover if the pointer has some strange bit >pattern representation then the NULL may not be passed correctly. > Even if pointers and integers are the same size and have the same representation, you are still in trouble if your compiler passes int parameters and pointer parameters via different mechanisms. In such a case, omitting both the prototype and the cast will mean that the *entire* parameter list will be received incorrectly by my_func(). Yes, such compilers exist, and yes, I have been bitten by one after forgetting the casts. ----------------------------------------------------------------------------- Alex Pensky ...!{cwjcc,decvax,pyramid,uunet}!abvax!aep (216)646-5211 Allen-Bradley Company 747 Alpha Drive, Highland Heights, OH 44143 -----------------------------------------------------------------------------