windows-d icon indicating copy to clipboard operation
windows-d copied to clipboard

Untyped unions gets translated into typed unions.

Open maternsta opened this issue 4 years ago • 1 comments

For example (in multimedia.d)

// C version
typedef struct {
  WAVEFORMATEX Format;
  union {
    WORD wValidBitsPerSample;
    WORD wSamplesPerBlock;
    WORD wReserved;
  } Samples;
  DWORD        dwChannelMask;
  GUID         SubFormat;
} WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE;

becomes

// D version
struct WAVEFORMATEXTENSIBLE
{
align (1):
    WAVEFORMATEX Format;
union Samples
    {
    align (1):
        ushort wValidBitsPerSample;
        ushort wSamplesPerBlock;
        ushort wReserved;
    }
    uint         dwChannelMask;
    GUID         SubFormat;
}

The same problem happens in direct3d11.d too but here its a unnamed struct becoming a type.

typedef union D3D11_AUTHENTICATED_PROTECTION_FLAGS {
  struct {
    UINT ProtectionEnabled : 1;
    UINT OverlayOrFullscreenRequired : 1;
    UINT Reserved : 30;
  } Flags;
  UINT                                   Value;
} D3D11_AUTHENTICATED_PROTECTION_FLAGS;

becomes

///Specifies the protection level for video content.
union D3D11_AUTHENTICATED_PROTECTION_FLAGS
{
struct Flags
    {
        uint _bitfield12;
    }
    uint Value;
}

maternsta avatar Jun 25 '21 11:06 maternsta

I don't think this is a bug. These unions and structs aren't unnamed; their names are just in different places. Regardless, I don't believe this changes program behavior or results in erroneous execution.

ethindp avatar Nov 28 '22 06:11 ethindp