Help me cast this!

Alan Myrvold ajmyrvold at violet.waterloo.edu
Tue May 3 21:15:43 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?
...
>	struct outfile {
>		int j;
>		int k;
>	} (*output)[];
>
>	output = malloc(sizeof(struct outfile) * 3);

Did you try :
	output = (struct outfile **) malloc(sizeof(struct outfile) * 3);

This goes through lint here, althougth lint complains that
        sizeof(struct outfile) * 3
is long, and should be unsigned.

So 
	output = (struct outfile **) malloc((unsigned)
                    sizeof(struct outfile) * 3);
should clear everything up.


-------------------------------------------------------------------
Si je t'aime? Bien sur que je t'aime! Ne suis-je pas en train de
te le prouver encore une fois, dans ce lit? 
-------------------------------------------------------------------
Alan Myrvold     ajmyrvold at violet.waterloo.edu
-------------------------------------------------------------------



More information about the Comp.lang.c mailing list