From c3ac60dacc8d11602ba9003397d7baffd6b6d338 Mon Sep 17 00:00:00 2001 From: Richard Stallman Date: Mon, 19 Sep 2022 21:17:12 -0400 Subject: [PATCH] (Structure Constructors): Give example with labeled fields. --- c.texi | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/c.texi b/c.texi index 2347ecf..e7f97d2 100644 --- a/c.texi +++ b/c.texi @@ -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: