On 8/28/19 5:00 AM, Dmitry Timoshkov wrote:
Zebediah Figura z.figura12@gmail.com wrote:
- struct http_receive_request_params params =
- {
.addr = (ULONG_PTR)request,
.id = id,
.flags = flags,
.bits = sizeof(void *) * 8,
- };
Please don't do this, it won't build with some compilers.
Do you mean the use of designated initializers?
Yes. It's pretty easy to avoid it, and there's no any real need to abuse this kind of strange syntax.
We've had those in the code base for over 6 years:
https://source.winehq.org/git/wine.git/commitdiff/cf0334b6542 https://source.winehq.org/git/wine.git/commitdiff/0fa08f47937e
Looks like this slipped through somehow.
Do you have a concrete example of a compiler that doesn't recognize these?
PSDK compiler chokes on it, and I already had to patch locally that windowscodecs test in order to build it.
It would have been nice to mention it before, then, because I've been using it rather extensively in quartz. In this instance I suppose one could just as easily use a series of decalarations, but I find designated initializers to be much easier to work with than non-designated initializers, as one does not need to remember the order of the fields, or change its users when the structure declaration changes, or add a large number of 0/NULL entries for sparsely initialized structures.
For what it's worth, support for designated initializers was introduced in Visual Studio 2013, and the cl.exe shipped with the Windows 10 SDK supports them.