-
Notifications
You must be signed in to change notification settings - Fork 531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why is struct DROPFILES packed(1)? #669
Comments
This has me confused, too. First, the technical reason is that the ShlObj_core.h SDK header file has an #include <pshpack1.h> directive right at the top, so the packing winds up in the metadata, and re-surfaces in the generated code. In the specific case of DROPFILES it appears, that It would certainly be nice to have a more versatile structure definition, in case the stronger packing requirement doesn't change the structure layout. The code generator could omit the packing attribute, if it can determine, that it is superfluous. The Layout type seems to provide all the required building blocks to determine this. Except, there's more to structure packing than packing: I suppose the only safe option here is to follow C, which relaxes the alignment requirements for packed structures on all 3 major C++ compilers. A corollary of this is that you cannot have references into a packed structure without exhibiting undefined behavior. This tracking issue illustrates workarounds. |
Right, the packing comes from metadata. If you can make a case for the packing not affecting the struct's layout you can create an issue here to request this be dropped: |
I also created an issue to improve trait coverage for such types. #656 |
This causes warning (borrow of packed field is unsafe and requires unsafe function or block (error E0133)) when accessing fields.
The text was updated successfully, but these errors were encountered: