ghaerr commented on PR #19912:
URL: https://github.com/apache/nuttx/pull/19912#issuecomment-5860582611
> I tried adding #pragma pack(2) to MWDLGTEMPLATE on my machine, but it does
not work. It looks like the reason is that the members of MWDLGTEMPLATE carry
the PACKEDDATA macro (__attribute__((packed)) on each member), which removes
the alignment requirement entirely.
It seems the structures are identical except that MWDLGTEMPLATE uses a
non-packed 'char extradata[1]` member, which I am guessing perhaps tells your
compiler the structure as a whole is 4-byte aligned. Perhaps adding PACKEDDATA
to that member declaration and possibly also to the structure itself may get
the compiler to think both structure pointers are 1-byte aligned, rather than
1- and 4-byte aligned; something like the following:
```
typedef struct tagMWDLGTEMPLATE
{
DWORD style;
DWORD dwExtendedStyle;
WORD PACKEDDATA cdit;
short PACKEDDATA x;
short PACKEDDATA y;
short PACKEDDATA cx;
short PACKEDDATA cy;
/* other information that follows, var length */
char PACKEDDATA extraData[1]; // <--- add PACKEDDATA here
} PACKEDDATA MWDLGTEMPLATE, *PMWDLGTEMPLATE; // <--- as well as here
```
> To move forward with NuttX, I suggest only to suppress warning for now.
Agreed this may be the best option to avoid introducing other potential
problems. But rather than muddying Microwindows .c source files with \#ifdef
NUTTX statements just to remove a warning for your build, I suggest putting the
GCC \#pragma in the config.nuttx file instead, so the warning(s) will always be
suppressed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]