machine generated code and chatty compilers
Peter Curran
peter at isgtec.UUCP
Tue Jan 23 02:53:14 AEST 1990
In article <340016 at hplvli.HP.COM> boyne at hplvli.HP.COM (Art Boyne) writes:
]The problem is: once you *have* investigated the warnings, how do you
]get the compiler to *shut up* on an individual warning in future compiles?
]I don't want a global shut-up flag, even on a particular class of errors,
]because, in the course of modification, I still might make that class of
]error. Lint does have some comment-directives to tell it to not flag
]individual instances of questionable code; ought not the compiler have the
]same feature?
]
]Example: we build instruments at this site, and use a standard parser for
]interpreting instrument commands. It calls all execution routines with
]three arguments: input parameter list ptr, output result list ptr, and a
]miscellaneous ptr (ie. *in, *out, *misc), where either *in or *out or both
]may be null, depending on the command. Well, that means a lot of routines
]never use at least one of the input parameters, and our lousy chatty compiler
]generates warnings for *each* unused parameter in *each* routine. Needless
]to say, it is easy to miss a new warning amidst the (numerous) old.
]
]Art Boyne, boyne at hplvla.hp.com
One solution is to add
assert(parmx == NULL);
for the unused parameters. This shuts the compiler up (except when you
are compiling the final version for "production" use, by which time you
presumably know that the warnings can be ignored), and has the benefit of
making sure the caller is using the function correctly. (Of course, it
is technically valid to pass a non-NULL value for the unused parameters,
but I would think it would be good practice to disallow it - when it occurs,
it probably indicates some kind of confusion.)
--
Peter Curran ...uunet!utai!lsuc!isgtec!peter isgtec!peter at censor
A scientist generates new ideas. A good engineer makes things work with as
few original ideas as possible. - Freeman Dyson
ISG Technologies Inc. 3030 Orlando Dr. Mississauga, Ont. Canada L4V 1S8
More information about the Comp.lang.c
mailing list