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

AP_Compass: fix C++ One Definition Rule violations #25585

Merged
merged 1 commit into from
Nov 21, 2023

Conversation

tpwrules
Copy link
Contributor

@tpwrules tpwrules commented Nov 20, 2023

Two structs with the same name must have exactly the same definition, no matter where they occur in the program, otherwise the program is undefined. This problem is diagnosed by the compiler when LTO is enabled (which it currently not for Ardupilot).

Move each sample register struct definition into the associated class definition so they are in a different namespace and no longer identically named, thus fixing this issue.

There is no code size or functional change. Supersedes #25394

Two structs with the same name must have exactly the same definition, no
matter where they occur in the program, otherwise the program is undefined.

Move each sample register struct definition into the associated class
definition so they are in a different namespace and no longer
identically named, thus fixing this issue.
Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

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

LGTM

@peterbarker peterbarker merged commit b8d50b1 into ArduPilot:master Nov 21, 2023
@tpwrules tpwrules deleted the fix-compass-odr-violations branch November 21, 2023 02:29
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.

2 participants