C and lint: default declarations

Doug Gwyn gwyn at smoke.BRL.MIL
Sun Jan 22 01:20:17 AEST 1989


In article <501 at larry.UUCP> jwp at larry.UUCP (Jeffrey W Percival) writes:
>The question is, do "good" programmers typically take advantage of these
>concessions, or do they assiduously declare their integer functions and
>keep their "scopes" as collapsed as possible?

Both approaches are considered proper, since both remain within the
official definition of the language.

Personally, I declare all externs (not done by headers) just after
the inclusion of headers near the start of the source file.
Occasionally this catches a bug that would otherwise be hard to find.
More importantly, it documents the interdependency between modules.

Usually, when I need some variables with extremely localized scope
and a function call doesn't seem appropriate, I'll declare the
variables in a local block.  Besides protecting against bugs, this
also helps some compilers do a better job of register allocation.

>Does anyone have a lint-like tool that does not pander to these
>"forgiving" scope rules and default declarations?

There are many variants of "lint", but I don't recall hearing of
one that would squawk about legal use of implied function declaration.



More information about the Comp.unix.questions mailing list