Struct that apparently defines no instances in Unix v6 Struct that apparently defines no instances in Unix v6 unix unix

Struct that apparently defines no instances in Unix v6


If someone included the whole file in a union declaration, it would allow them to access the different parts.

It would be something like:

  union{   #include <param.h>  } myparam;  myparam.integ = 0xDEAD;  assert(myparam.lobyte == 0xAD)  assert(myparam.hibyte == 0xDE)

(Depends on endianness of architecture...)

So having looked around a bit, it seems that in old versions of C, you wouldn't have needed to declare the union ; there was only one namespace for all struct/union members that just translated into a byte offset that you could use on any variable. The best mention of this I could find is here : http://docs.sun.com/source/806-3567/compat.html Describing pre-ISO Sun C:

Allows struct, union, and arithmetic types using member selection operators ('.', '->') to work on members of other struct(s) or unions.


Back in those days, the members of structures all shared the same namespace, not one namespace per structure. Consequently, each element of a structure had to have a unique name across all structures, or the same element had to appear with the same type at the same offset in every structure in which it appeared. Quite how that was used with these, I'm not sure, but I suspect you could do:

int x;x.lobyte = 1;x.hibyte = 2;

Or something analogous to that.

See also:

(Neither of those seems to answer this question, though.)