LINT NOSTRICT MACRO
sam at tyxpdp.UUCP
sam at tyxpdp.UUCP
Fri Sep 21 06:44:09 AEST 1984
A lint macro definition has proved to be useful at our shop.
#ifdef lint
#define NOSTRICT(type,exp) ((exp) ? type 0 : type 0)
#else
#define NOSTRICT(type,exp) (type (exp))
#endif
With the NOSTRICT macro, lint complaints about casts of expressions
are quieted for the desired expression, with full evaluation of
any sub-expressions.
The most useful place is with malloc(), which is typed char *,
being cast to (struct type *). Example:
structpointer = NOSTRICT((struct type *),malloc(sizeof struct type));
The macro utilizes a property of the conditional operator,
where the type of the first expression does not affect the
type of the result.
---
Jeffrey Kegler @ tyxpdp
TYX Corporation
11250 Roger Bacon Drive Suite 16
Reston Va 22090
(703) 471-0233
uucp - decvax!harpo!seismo!umcp-cs!tyxpdp!jeffrey
--
---
Sam Chessman - sam at tyxpdp
TYX Corporation
11250 Roger Bacon Drive Suite 16
Reston Va 22090
(703) 471-0233
uucp - decvax!harpo!seismo!umcp-cs!tyxpdp!sam
More information about the Comp.unix.wizards
mailing list