Skip to content
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

Fix marshalling bool parameters and return values in pInvokes #106

Merged

Conversation

hoffmann-stefan
Copy link
Member

@hoffmann-stefan hoffmann-stefan commented May 19, 2023

extracted from #94

This fixes Issues with bools that where interpreted wrong in release builds and therefore causing wrong behavior.

See https://www.mono-project.com/docs/advanced/pinvoke/#boolean-membersfor more information on marshalling bools.

Took the following path:

  • Use int on C# side and int32_t on the c side instead of bool for the library code to make this as explicit as it gets and avoid bool entirely.
  • Use bool on C# side and int32_t on the c side in the messages code. This avoids having to ad special cases to the C# template for the code generation. As bools in C# pInvokes get marshalled as 32 bit integer by default there is no need to change the code for bool fields.

This does not change the C# side of the generated messages to avoid even more complexity in the templates.
As bools in C# pInvokes get marshalled as 32 bit integer by default there is no strictly need to change the code for bool fields.
@hoffmann-stefan hoffmann-stefan force-pushed the feature/fix-bool-pInvoke branch from e8da301 to 86b182c Compare May 26, 2023 13:43
@hoffmann-stefan hoffmann-stefan merged commit 5680d66 into ros2-dotnet:main May 26, 2023
@hoffmann-stefan hoffmann-stefan deleted the feature/fix-bool-pInvoke branch May 26, 2023 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant