(Structure Constructors): Give example with labeled fields.

This commit is contained in:
Richard Stallman 2022-09-19 21:17:12 -04:00
parent 2f8e7ba6d5
commit c3ac60dacc
1 changed files with 8 additions and 0 deletions

8
c.texi
View File

@ -6687,6 +6687,14 @@ expression (@pxref{Statement Exprs}):
@})
@end example
You can also use field labels in the structure constructor to indicate
which fields you're specifying values for, instead of using the order
of the fields to specify that:
@example
(struct foo) {.a = x + y, .b = {'a', 0}}
@end example
You can also create a union value this way, but it is not especially
useful since that is equivalent to doing a cast: