Help me cast this!
Larry Miller
lmiller at venera.isi.edu
Thu May 5 02:32:00 AEST 1988
In article <294 at fedeva.UUCP> wrd3156 at 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 at venera.isi.edu (no uucp)
USC/ISI 213-822-1511
4676 Admiralty Way
Marina del Rey, CA. 90292
More information about the Comp.lang.c
mailing list