Source File Organization

Peter Kriens pkr at media01.UUCP
Wed Feb 27 09:34:13 AEST 1991


> typedef enum { A, B, C, D } CMD;
> and a corresponding array of ascii representations :
> char ltrs[] = { 'A', 'B', 'C', 'D' };
...
> The problem is exacerbated by the fact that the CMD enum,
> being a typedef, is in a header file that is included in
> many places.  Since ltrs[] is an instantiated variable, it
> *can't* live in the same place.  Where should it live?

You could place the table in the header file like

	typedef enum { A, B, C, D ) CMD;
	#ifdef _CMDDEF_
	char ltrs = { 'A', 'B', 'C', 'D' };
	#endif

This would at least take care of the fact that they are close together
which means that the change of noth being updated simulteneous is actually
not zero. The only thing you have to do in the source that is allowed
to define the table ltrs, is defining _CMDDEF_ before you include the
header file

Peter Kriens



More information about the Comp.lang.c mailing list