declarations in include files: how do YOU feel?

Jeffrey W Percival jwp at larry.sal.wisc.edu
Thu May 11 07:42:25 AEST 1989


I would like to find out how the "experts" feel about a coding
practice, so I don't develop a bizarre style (bizarre with respect
to the general body of usage).  I hope this doesn't start a
philosophy war of some kind.

The situation is, suppose I have a bunch of routines that are packaged
into a lib.a, and there is an associated include file "lib.h" that
users need to include.  Should the lib.h file contain extern declarations
for everything in lib.a, or not?

case 1:  shotgun approach.  declare all the routines contained in lib.a
advantage:  user doesn't need to.
disadvantage: "scope" is not micro-managed.  labels are in scope
everywhere, even labels not used in actual references.

case 2:  "anal" approach.  no declarations in lib.h.  User needs
to type in the declarations in every function that makes a reference.
advantage (???): user sees declarations in same file as usage.
scope of labels is managed according to program design.

If my goal is to be portable and non-eccentric, what should I do?
-- 
Jeff Percival (jwp at larry.sal.wisc.edu)



More information about the Comp.lang.c mailing list