Path: utzoo!mnetor!uunet!husc6!bloom-beacon!gatech!purdue!decwrl!hplabs!sdcrdcf!trwrb!aero!venera.isi.edu!lmiller From: lmiller@venera.isi.edu (Larry Miller) Newsgroups: comp.lang.c Subject: Re: Help me cast this! Message-ID: <5426@venera.isi.edu> Date: 4 May 88 16:32:00 GMT References: <294@fedeva.UUCP> Reply-To: lmiller@venera.isi.edu.UUCP (Larry Miller) Organization: Information Sciences Institute, Univ. of So. California Lines: 33 Keywords: pointer to array of struct In article <294@fedeva.UUCP> wrd3156@fedeva.UUCP (Bill Daniels) writes: > >How do I cast the malloc() in line 12 of the following program to avoid >the lint cries of "warning: illegal pointer combination" et al? > >main() >{ > char *malloc(); > int i; > struct outfile { > int j; > int k; > } (*output)[]; > > output = malloc(sizeof(struct outfile) * 3); Probably seen 100s of these by now, but here goes: % cdecl cast malloc into pointer to array of struct outfile Warning: Unsupported in C -- Pointer to array of unspecified dimension (struct outfile (*)[])malloc(sizeof(struct outfile) * 3); NOTE the warning!! And note that the cast is almost the same as the definition of output, only the name is removed. Larry Miller lmiller@venera.isi.edu (no uucp) USC/ISI 213-822-1511 4676 Admiralty Way Marina del Rey, CA. 90292