From: Jeff King Date: Wed, 11 Jan 2023 20:30:16 GMT Subject: Re: [PATCH 0/5] cleaning up read_object() family of functions Message-ID: In-Reply-To: <6c896cc8-2da9-a448-4ab6-2dc535fb0e2b@github.com> On Wed, Jan 11, 2023 at 03:17:58PM -0500, Derrick Stolee wrote: > > For example, here's an attempt to let the caller use designated > > initializers to set up the query struct: > > > + struct object_info oi = OBJECT_INFO(.typep = type, > > + .sizep = size, > > + .contentp = &data); > > Your macro expansion creates this format: > > struct object_info oi = { > .type = type, > .sizep = size, > .contentp = &data, > }; > > And even this expansion looks a bit better than the inline > updates: There's a subtle assumption in the expanded initializer, though, which is that everything not specified is OK to be zero-initialized. That works for object_info, but not for arbitrary structs (which is why we have these INIT macros in the first place). -Peff