Closed
Description
Take the following example:
class RECT extends Struct {
@Int32()
external int left;
@Int32()
external int top;
@Int32()
external int right;
@Int32()
external int bottom;
}
@Packed(1)
class MCI_DGV_CAPTURE_PARMS extends Struct {
@IntPtr()
external int dwCallback;
external Pointer<Utf16> lpstrFileName;
external RECT rc;
}
FFI complains with the error:
Nesting the non-packed or less tightly packed struct 'RECT' in a packed struct 'MCI_DGV_CAPTURE_PARMS' is not supported.
Try packing the nested struct or packing the nested struct more tightly.dart(packed_nesting_non_packed)
This is unnecessarily restrictive. The equivalent C code is fine, as best as I can infer (here's the original that I'm mapping):
#pragma pack(1)
typedef struct {
DWORD_PTR dwCallback;
LPWSTR lpstrFileName;
RECT rc;
} MCI_DGV_CAPTURE_PARMS;
...
and in a separate file without a #pragma
directive:
typedef struct tagRECT
{
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECT, *PRECT, NEAR *NPRECT, FAR *LPRECT;
Any thoughts, @dcharkes? Marking RECT
with @Packed(1)
is not an option, since this is being auto-generated from the original header file.