Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!amdcad!ames!mailrus!tut.cis.ohio-state.edu!ukma!uflorida!novavax!proxftl!bill From: bill@proxftl.UUCP (T. William Wells) Newsgroups: comp.lang.c Subject: Re: lint on malloc calls Keywords: malloc lint pointer Message-ID: <745@proxftl.UUCP> Date: 13 Sep 88 01:41:42 GMT References: <39617@linus.UUCP> Reply-To: bill@proxftl.UUCP (T. William Wells) Organization: Proximity Technology, Ft. Lauderdale Lines: 38 Summary: Expires: Sender: Followup-To: Distribution: In article <39617@linus.UUCP> jgb@linus.UUCP (Jonathan G. Bressel) writes: : What is the best way of using malloc to get a pointer to a structure? : I am using the line below: : : nextentry = (entry *) malloc(sizeof(entry)); : : where nextentry is defined as : : entry *nextentry; : : 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 are using lint. :-) This is a problem with every lint I have used. Lint doesn't understand that malloc returns a properly aligned pointer, so you get the messages. To shut lint up, you need to trick it a little. Here is one way: Place #ifdef lint /* lint defines this symbol */ #define malloc(x) 0 #endif somewhere so that every call to malloc can be overridden by the macro. You may want to put a #undef malloc in front of the #define. --- Bill novavax!proxftl!bill