[1/2] kernel32/tests: Fix compilation with PSDK.

Dmitry Timoshkov dmitry at baikal.ru
Wed Aug 19 07:53:33 CDT 2015


Michael Stefaniuc <mstefani at redhat.com> wrote:

> > -    char buf[FIELD_OFFSET(JOBOBJECT_BASIC_PROCESS_ID_LIST, ProcessIdList[5])];
> > +    char buf[sizeof(JOBOBJECT_BASIC_PROCESS_ID_LIST) + sizeof(ULONG_PTR) * 5];
> this change looks odd.
> 
> Using offsetof (or FIELD_OFFSET) is the standard Wine way of getting the
> size of a struct with a variable length array. I have done quite a few
> patches on Alexandre's request that replace sizeof+sizeof*x with
> offsetof. E.g. 14e20162f9448a648f3973a86e03aea17387c040

Well, it was already discussed before, MSVC/PSDK compilers don't cope with
such a construct, FIELD_OFFSET() is not a constant for them, and they fail.
An ability to compile with MSVC/PSDK compilers is very critical thing at least
for writing Wine tests, so we have to take that limitation into account.

> Last but not least you're not allocating the same amount of memory:
>   offsetof(struct, field[n]) == sizeof(struct) + (n-1) * sizeof(field)

Yes, I decided to make it visible that 5 fields are explicitely allocated
instead of adding a comment that 1 field is already allocated in the base
structure, but it shouldn't matter.

-- 
Dmitry.



More information about the wine-devel mailing list