Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!algor2!jeffrey From: jeffrey@algor2.uu.net (Jeffrey Kegler) Newsgroups: comp.lang.c Subject: Re: 2 lint questions Message-ID: <1989Aug16.152316.24402@algor2.uu.net> Date: 16 Aug 89 15:23:16 GMT References: <5967@ingr.com> Reply-To: jeffrey@algor2.UUCP (Jeffrey Kegler) Organization: Algorists, Inc. Lines: 30 In article <5967@ingr.com> 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)); #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))); This solves all complaints about casts, possible loss of precision, etc. Note the expression exp is still type-checked by lint, so you are turning lint off only on the cast. I believe in making lint absolutely silent, that is, lint returns nothing but another shell prompt. Otherwise, lint messages pile up and it becomes impossible to sort out that there are now 16 "possible loss of precision" messages instead of 15 and the new one ain't just crying wolf, either. This is particularly true is you are not the only one who worked on the code. -- Jeffrey Kegler, Independent UNIX Consultant, Algorists, Inc. jeffrey@algor2.ALGORISTS.COM or uunet!algor2!jeffrey 1762 Wainwright DR, Reston VA 22090