header file duplicate definitions advice sought

Doug Gwyn gwyn at smoke.brl.mil
Mon Mar 11 08:14:38 AEST 1991


In article <CRACRAFT.91Mar7214134 at pogo.ai.mit.edu> cracraft at pogo.ai.mit.edu (Stuart Cracraft) writes:
>How can you eliminate redefined errors in C when you have several thousand 
>"#define"'s defined in both *.h and *.c files(about 2000 files combined)?

(This is more appropriate for comp.lang.c.)

The basic problem you have is that C supports only a few "flat" name
spaces.  Thus, if one wishes to properly package related sets of
identifiers without conflict among multiple packages, one has to
devise his own packaging scheme.  For BRL's MUVES project we reserved
the first two characters of "visible" (extern, macro, and file)
identifiers to denote the specific package, and maintained a central
registry of package names.  Of course each package had a header that
defined its visible interface.

There is NO satisfactory way to handle a situation such as you
describe, where insufficient care was taken in designing the interfaces.



More information about the Comp.unix.questions mailing list