Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!rutgers!aramis.rutgers.edu!paul.rutgers.edu!jac From: jac@paul.rutgers.edu (Jonathan A. Chandross) Newsgroups: comp.lang.c Subject: Re: 2 lint questions Message-ID:Date: 16 Aug 89 21:04:01 GMT References: <5967@ingr.com> <1989Aug16.152316.24402@algor2.uu.net> Organization: Rutgers Univ., New Brunswick, N.J. Lines: 38 boyd@ingr.com (Boyd Nation) writes: >1) How does one prevent lint from issuing a warning message about possible >pointer alignment problems given the following line of code: > x = (blivet *)malloc(sizeof(blivet)); jeffrey@algor2.uu.net (Jeffrey Kegler) > #ifdef lint > #define NOSTRICT(type, exp) ((exp)?(type)0:(type)0) > #else > #define NOSTRICT(type, exp) ((type)(exp)) > #endif > so that the expression above becomes > x = NOSTRICT(blivet *,malloc(sizeof(blivet))); I use an entirely different approach. I declare a fake malloc: void *my_malloc(size) unsigned int size; { extern char *malloc(); return((void *)malloc(size)); } and then whenever I use it I say something like: .... extern void *my_malloc() ZAP *zap_pntr = (ZAP *)my_malloc((U_INT)sizeof(ZAP)); This shuts up lint except for the line in my_malloc where I cast from char * to void *. I figure that 1 ignorable complaint is better than hundreds of them. Jonathan A. Chandross Internet: jac@paul.rutgers.edu UUCP: rutgers!paul.rutgers.edu!jac