3 ms·
Unions would be nice if the syntax for accessing substructure members could be nominally short circuited. For example: struct ab { int a; int b; }; union
by benlorenzetti 9y ago
Unions would be nice if the syntax for accessing substructure members could be nominally short circuited. For example:
struct ab {
int a;
int b;
};
union c {
struct ab ab_short_circuit;
int a;
};
union c c1;
c1.a = 1;
c1.b = 2;
- cesarb 9y agoThat already exists, as a Microsoft extension, and if the struct is declared within the union, in standard C: https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/Unnamed-Fields.html https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/Unnamed-Fields.... (However, in your example, c1.a is ambiguous, so it won't compile.)
- benlorenzetti 9y agoI did not realize this as a Linux user--thanks. (But this is my point, it is should not be ambiguous.)