struct Lock {
int val;
};
void lock(Lock*);
void unlock(Lock*);
struct Object {
Lock;
int data;
};
Object *o;
lock(o);
o->data;
o->val;
unlock(o);
/* same as: unlock(&o->Lock); */
Structure elements of structure type can be declared anonymously. All the elements in the anonymous structure are available in its containing structure. The containing structure can be passed to a function expecting a pointer to the anonymous structure.
The anonymous element can be named by its type, as in o->Lock in the example.
Anonymous elements need not be the first element in a structure. In this case, the compiler must translate the pointer appropriately when converting it to be passed to a function.
Inspired by similar support in the Plan 9 C Compiler.
Not implemented.