@@ -253,7 +253,7 @@ $(H3 $(LNAME2 default_struct_init, Default Initialization of Structs))
253
253
254
254
$(P Struct fields are by default initialized to whatever the
255
255
$(GLINK2 declaration, Initializer) for the field is, and if none is supplied, to
256
- the default initializer for the field's type.
256
+ the $(DDSUBLINK spec/property, init, default initializer) for the field's type.
257
257
)
258
258
259
259
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
@@ -281,19 +281,22 @@ $(GNAME StructMemberInitializer):
281
281
$(GLINK_LEX Identifier) $(D :) $(GLINK2 declaration, NonVoidInitializer)
282
282
)
283
283
284
- $(P If a $(I StructInitializer) is supplied, the
285
- fields are initialized by the $(I StructMemberInitializer) syntax.
286
- $(I StructMemberInitializers) with the $(I Identifier : NonVoidInitializer) syntax
287
- may be appear in any order, where $(I Identifier) is the field identifier.
288
- $(I StructMemberInitializer)s with the $(GLINK2 declaration, NonVoidInitializer) syntax
289
- appear in the lexical order of the fields in the $(GLINK StructDeclaration).
290
- )
284
+ $(P If a $(I StructInitializer) is supplied,
285
+ each $(I StructMemberInitializer) initializes a matching field:)
286
+
287
+ * A $(I StructMemberInitializer) using the $(I Identifier : NonVoidInitializer) syntax
288
+ may appear in any order. The identifier must match a field name.
289
+ * If the first $(I StructMemberInitializer) does not specify an *Identifier*,
290
+ it refers to the first field in the $(GLINK StructDeclaration).
291
+ * A subsequent *NonVoidInitializer* without an *Identifier* refers to the next field
292
+ (in lexical order) after the one referred to in the previous *StructMemberInitializer*.
291
293
292
- $(P Fields not specified in the $(I StructInitializer) are default initialized.)
294
+ $(P Any field not covered by a $(I StructMemberInitializer) is default initialized.)
293
295
294
296
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
295
297
---
296
298
struct S { int a, b, c, d = 7; }
299
+
297
300
S r; // r.a = 0, r.b = 0, r.c = 0, r.d = 7
298
301
S s = { a:1, b:2 }; // s.a = 1, s.b = 2, s.c = 0, s.d = 7
299
302
S t = { c:4, b:5, a:2, d:5 }; // t.a = 2, t.b = 5, t.c = 4, t.d = 5
@@ -342,8 +345,10 @@ $(H3 $(LNAME2 default_union_init, Default Initialization of Unions))
342
345
343
346
$(H3 $(LNAME2 static_union_init, Static Initialization of Unions))
344
347
345
- $(P Unions are initialized similarly to structs, except that only
346
- one member initializer is allowed.)
348
+ $(P Unions are initialized
349
+ $(RELATIVE_LINK2 static_struct_init, similarly to structs), except that only
350
+ one member initializer is allowed. If the member initializer does not specify
351
+ an identifier, it will initialize the first member of the union.)
347
352
348
353
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
349
354
---
0 commit comments