Skip to content

Add discussion of platform sensitive struct/union layout - #18087

Merged
gewarren merged 9 commits into
masterfrom
AaronRobinsonMSFT-patch-1
Apr 28, 2020
Merged

gewarren merged 9 commits into
masterfrom
AaronRobinsonMSFT-patch-1

Conversation

@AaronRobinsonMSFT

Copy link
Copy Markdown
Member

Summary

Add discussion for platform sensitive struct/union layout.

/cc @gewarren @danmosemsft @elinor-fung @jkoritzinsky

@AaronRobinsonMSFT

Copy link
Copy Markdown
Member Author

This new content applies to both .NET Framework and .NET Core.

@BillWagner
BillWagner requested review from gewarren and removed request for a team April 27, 2020 13:30

@gewarren gewarren left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this. I left some grammatical/flow suggestions.

@jkoritzinsky

Copy link
Copy Markdown
Member

Another thing that might be worth mentioning here is that if instead of creating one explicit struct, if you create a sequential structure for STREET with a nested explicit structure with everything at offset 0 that represents the implicit union field, then you don't need two definitions to account for bitness. Alignment considerations should automatically handle layout cross-bitness in that scenario.

@AaronRobinsonMSFT

Copy link
Copy Markdown
Member Author

Another thing that might be worth mentioning here is that if instead of creating one explicit struct, if you create a sequential structure for STREET with a nested explicit structure with everything at offset 0 that represents the implicit union field, then you don't need two definitions to account for bitness. Alignment considerations should automatically handle layout cross-bitness in that scenario.

@jkoritzinsky That could be possible, but that may not be true for COM-RPC. How the structs are defined and that they can be different based on bitness is the intent of this sample. The above workaround could work in some scenarios but it could also fail in others. We should avoid those kind of tricks in official documentation.

@gewarren

Copy link
Copy Markdown
Collaborator

Looks good. I'm not sure if you have write permissions, so I'm merging this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants