Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ames!mailrus!tut.cis.ohio-state.edu!rutgers!rochester!pt.cs.cmu.edu!cadre!pitt!darth!apexepa!gary From: gary@apexepa.UUCP (Gary Wisniewski) Newsgroups: comp.sys.ibm.pc Subject: Re: Function declarations (was: MSC Summary: Not quite ... Message-ID: <344@apexepa.UUCP> Date: 13 Sep 88 16:51:37 GMT References: <64@cybaswan.UUCP> <12400016@cpe> Reply-To: gary@apexepa.UUCP (Gary Wisniewski) Organization: Apex Software Corp., Pittsburgh, Pa. Lines: 33 In article <12400016@cpe> tif@cpe.UUCP writes: > >Written 6:40 pm Sep 4, 1988 by bigtex.UUCP!james in cpe:comp.sy.ibm.pc >>It's worse than all that. ANSI C permits conflicting function >>declarations without a warning - indeed it is required that no warning >>... and I can't conceive of any >>implementation where the ANSI C requirement is actually useful. > >I can. When you want to use a return value in more than one way. > >a() { > int *malloc(), *x; > x = malloc(sizeof(int)); >} > >b() { > long *malloc(), *x; > x = malloc(sizeof(long)); >} You can get away with this, but donn your asbestos suit if you say this in comp.lang.c! This won't work for machines which have different pointer formats for different data types. char *malloc(); long *x; x = (long *) malloc(sizeof(long)); The above tells the compiler that it needs to explicitly coerce a char* to a long*. Your code above just assumes that malloc returns a long*; not valid on many machines (Data General, for instance). -- Gary J. Wisniewski Apex Software Corporation {allegra,bellcore,cadre}!pitt!darth!apexepa!gary Phone: (412) 681-4343