ghaerr commented on PR #19912: URL: https://github.com/apache/nuttx/pull/19912#issuecomment-5861230055
> I am not sure, because catching this kind of problem early has some worth. This isn't a new code problem, the referenced code is probably 20+ years old and both structures are properly packed for the members common between them. The new issue seems to be the compiler being used on NuttX is now defining an error on very old code that's worked for years on other systems. > This location is specially problematic due for MS unclear definition I don't see how MS documentation affects this issue: both structures are packed for common members. It seems to me this issue is one of comparing pointers to structures for equivalency, not whether any structure member referenced by the winres.c code is improperly packed or aligned improperly on certain CPUS: Both MWDLGTEMPLATE and DLGTEMPLATE structs are packed for all members prior to the `extradata` member. The source then makes clear clear that sizeof(struct DLGTEMPLATE) is 18 and packing required with the following code in include/winres.h: ``` #define FIXSZ_MWDLGTEMPLATE 18 ``` This define thus requires the compiler to pack the structure, regardless of required CPU architecture alignment. The code in winres.c uses FIXSZ_MWDLGTEMPLATE instead of sizeof(struct DLGTEMPLATE) to handle the seemingly potential current case of tagMWDLGTEMPLATE and DLGTEMPLATE alignment after end of structure difference (although mostly due to the 'extradata' member always causing the structures to have different sizes). > on the other hand for system without native unaligned support the code would be much longer and the problem propagates even to the caller subroutine. I'm not sure I follow here, proper operation for Win32 .res resource file interpretation necessarily requires compiler support for packed (unaligned) structures. For systems without native unaligned support, the winres.c routines will/would have to be rewritten - but I have never seen this required. > Changing the tagMWDLGTEMPLATE to match other structure would solve the problem, If you think so also, let's try it: change tagMWDLGTEMPLATE as suggested above, and the problem will then be fixed for both old and new compilers with no need for additional pragmas. -- 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]
