structure element offsets

Wayne Throop throopw at dg_rtp.UUCP
Tue Dec 9 01:59:49 AEST 1986


> dave at viper.UUCP (David Messer)
> for good or ill,
> C has been defined such that all members-of-structures share the
> same name-space.

You're wrong, you know.  Members of structures do NOT share the same
namespace in C, no more than =+ is an operator in C.  Let us chant
together, from Harbison and Steele, page 107:

    The names of structure components are defined in a special
    overloading class associated with the structure type.  That is,
    component names within a single structure must be distinct, but they
    may be the same as component names in other structures and may be
    the same as variable, function, and type names.

Kernighan and Ritchie have similar things to say, but I don't (GASP)
have my K&R to hand just now to find what they are, though I recall
vaguely that they explain that the historical crock that some compilers
(that aren't C compilers, mind you:-) make structure members of all
structure types a single namespace.  This historical oddity should not
be confused with a linguistic feature.

--
A LISP programmer knows the value of everything, but the cost of nothing.
                                --- Alan J. Perlis
-- 
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw



More information about the Comp.lang.c mailing list