Path: utzoo!mnetor!uunet!iscuva!carlp From: carlp@iscuva.ISCS.COM (Carl Paukstis) Newsgroups: comp.lang.c Subject: Re: Help me cast this! Message-ID: <1451@iscuva.ISCS.COM> Date: 3 May 88 23:38:46 GMT References: <294@fedeva.UUCP> Organization: ISC Systems Corporation, Spokane, WA Lines: 43 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? = =#include = =main() ={ = char *malloc(); = int i; = struct outfile { = int j; = int k; = } (*output)[]; = = output = malloc(sizeof(struct outfile) * 3); = = (*output)[0].j = 1; = (*output)[0].k = 2; = = i = printf("%d %d\n",(*output)[0].j,(*output)[0].k); = = return(i); =} =-- =bill daniels =federal express, memphis, tn ={hplabs!csun,gatech!emcard}!fedeva!wrd3156 output = (struct outfile **)malloc(sizeof(struct outfile) * 3); works on Ultrix 2.something, a Sys V "compliant" type system complains of "possible pointer alignment problem", presumably because "char" requires only byte alignment (returned from malloc), while "struct outfile *" requires halfword alignment (on 68010 systems). Maybe my lint is too good... I can't find a combination that passes clean on the Sys V system, either. -- Carl Paukstis +1 509 927 5600 x5321 |"I met a girl who sang the blues | and asked her for some happy news UUCP: carlp@iscuvc.ISCS.COM | but she just smiled and turned away" ...uunet!iscuva!iscuvc!carlp | - Don MacLean