Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!uwmcsd1!uxc!uxc.cso.uiuc.edu!a.cs.uiuc.edu!bradley!brian From: brian@bradley.UUCP Newsgroups: comp.lang.c Subject: Re: lint on malloc calls Message-ID: <9900007@bradley> Date: 10 Sep 88 23:43:00 GMT References: <39617@linus.UUCP> Lines: 35 Nf-ID: #R:linus.UUCP:39617:bradley:9900007:000:1090 Nf-From: bradley.UUCP!brian Sep 10 18:43:00 1988 > /* Written 3:12 pm Sep 8, 1988 by jgb@linus.UUCP */ [ edited for brevity ] > > entry *nextentry; > > nextentry = (entry *) malloc(sizeof(entry)); > > Running lint -bach yields: > > phone.c(61): warning: illegal pointer combination > phone.c(61): warning: possible pointer alignment problem > > What am I doing wrong? Doesn't K+R suggest this on pp. 133-134 (at > the end of section 6.5)? You probably didn't tell lint or cc what malloc() returns, so it assumed int malloc()... The warning is given because you have done an explicit cast of a pointer to an integer. Just add the following line to either the top of your program or the top of your function: extern char *malloc(); Or, if you compiler supports void* extern void *malloc(); ............................................................................... When the going gets weird, the weird turn pro. Brian Michael Wendt UUCP: {cepu,ihnp4,uiucdcs,noao}!bradley!brian Bradley University ARPA: cepu!bradley!brian@seas.ucla.edu (309) 677-2230 ICBM: 40 40' N 89 34' W