4 Aug
2025
4 Aug
'25
9:56 p.m.
On Mon Aug 4 21:54:09 2025 +0000, Vibhav Pant wrote:
The alignment padding is what makes packing necessary, I think. I couldn't come up with any other way to have one struct for 64 and 32 bit, unfortunately Could try something like
union hstring_wire
{
struct {
ULONG context;
} repr1;
struct {
ULONG context;
ULONG size;
WCHAR data[];
} repr2;
struct {
ULONG context;
#ifdef _WIN64
ULONG pad;
#endif
HSTRING str;
} repr3;
};
and you can read context from any of the members; https://en.cppreference.com/w/c/language/union.html says it will be type-punned, which doesn't do a whole lot of anything when it's ULONG already. (Or you can simply omit the padding member completely, and the compiler will insert the padding if needed. Does winehq have any policy on whether padding members should be explicit?) -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8703#note_112090