3 ms·
C99 added designated initializers and compound literals, and C11 added anonymous structs and unions of the kind you showed above. These are 3 of the biggest fea
by wahern 2mo ago
C99 added designated initializers and compound literals, and C11 added anonymous structs and unions of the kind you showed above. These are 3 of the biggest features Plan 9 added to C, and they were adopted relatively quickly. But there's another type of anonymous struct/union Plan 9 added; using a bare tag name, e.g. `struct foo { union bar; };` to implicitly define the members. And Plan 9 C will also automagically coerce (and adjust the pointer offset) a struct reference to a reference to a typed anonymous member when calling a function that takes the latter. And now that I think about it, this seems like the obvious predecessor to Go's duck typing.
- asveikau 2mo agoGCC and VC++ supported anonymous structs and unions long before C11.