declarations in include files: how do YOU feel?

Jeffrey W Percival jwp at larry.sal.wisc.edu
Fri May 12 10:08:34 AEST 1989


In article <10251 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
>In article <179 at larry.sal.wisc.edu> jwp at larry.sal.wisc.edu (Jeffrey W Percival) writes:
>>Should the lib.h file contain extern declarations for everything in lib.a?
>Otherwise, define/declare them all in lib.h.  If functions in lib.a
>can call other functions in lib.a, the user has to be aware of the
>total set of external names defined by the library anyway so that he
>doesn't accidentally usurp one for his application.  (That would break
>functions that called that usurped function.)

This appears to be the consensus, and it makes sense.  Thanks.

And besides, I think I thought up another reason:  what if the maintainer
of the lib.a decides to re-implement an existing function as a macro,
for example.  If the user has the thing appearing in an extern statement,
it might break.  If the user relies on the lib.h file to "make everything
OK", then the macro/function sleight of hand can proceed behind the scenes.

Is that interpretation unflawed?
-- 
Jeff Percival (jwp at larry.sal.wisc.edu)



More information about the Comp.lang.c mailing list