Help, page 197 K&R !!!

Doug Gwyn gwyn at smoke.BRL.MIL
Sun Jul 2 13:21:43 AEST 1989


In article <646 at kl-cs.UUCP> atula at cs.keele.ac.uk (Atula Herath) writes:
>"Two structures may share a common initial sequence of members; ..."
>What does that mean ?

This is explained in A8.3 in the second edition of K&R, which reflects
the current state of C structure member name constraints.  According
to K&R 1st ed., structure member names for all structure types together
constituted one big name space; however, that's not how C is currently
defined -- now each structure type has a private name space for its
members, so the same member name may be freely used in a variety of
declarations of different structures.  The cited quotation is simply
not relevant under the current member name space rules.

K&R 1st ed.:
	struct foo {
		int a;
		float b;
	};
	struct bar {
		int a;		/* legal */
		char c;
	};
	struct baz {
		double a;	/* illegal */
		int d;
	};
	struct bam {
		float e;
		int a;		/* illegal */
	};

All the above are legal according to modern rules.



More information about the Comp.lang.c mailing list