Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 SMI; site sun.uucp Path: utzoo!linus!decvax!decwrl!sun!gnu From: gnu@sun.uucp (John Gilmore) Newsgroups: net.bugs.2bsd,net.lang.c Subject: Re: Unique member names in structs Message-ID: <376@sun.uucp> Date: Thu, 8-Dec-83 06:03:38 EST Article-I.D.: sun.376 Posted: Thu Dec 8 06:03:38 1983 Date-Received: Sat, 10-Dec-83 02:26:20 EST References: <738@garfield.UUCP> <2895@utcsrgv.UUCP> <1454@rlgvax.UUCP> Organization: Sun Microsystems, Inc. Lines: 33 The other advantage to unique member names (besides portability to V7 and minor readability) is that you can substitute them with #define's. It's a royal pain to try to change a nonunique member name (which is why all the V7 people complain when we use them) -- it has to be done manually. While we're almost on the subject, does anybody have a better workaround for getting rid of the "extra member name" required when making a union? e.g. struct foo { char *name; union { int i; float f; } u; } node; You can't talk about "node.i" or "node.f", you have to say "node.u.i". I find this a royal pain and end up doing this: struct foo { char *name; union { int u_i; float u_f; } u; #define i u.u_i #define f u.u_f } node; Then I can say "node.i" and cpp turns it into "node.u.u_i" which works. However, "i" and "f" have to be unique in the whole program, since cpp doesn't know about scope (or that they only apply within struct foo's).