Path: utzoo!attcan!uunet!lll-winken!ncis.llnl.gov!helios.ee.lbl.gov!pasteur!ucbvax!ucsd!rutgers!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.unix.questions Subject: Re: C and lint: default declarations Message-ID: <9472@smoke.BRL.MIL> Date: 21 Jan 89 15:20:17 GMT References: <501@larry.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Followup-To: comp.lang.c Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 23 In article <501@larry.UUCP> jwp@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.