-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Identically names structs in different files #9099
Comments
Internal Jira reference: https://jira.arm.com/browse/MBOCUSTRIA-318 |
CC @ARMmbed/mbed-os-storage |
Does it just complain about every same-named type in different C files?
|
Ah, okay, this is a C++ wrinkle that had escaped me: unlike C, top-level types aren't totally hidden within a translation unit - you can't use the same name for two different types in two different translation units. Simplest fix here seems to be to just stick an anonymous namespace Does the LTO cope if without complaint if you have matching structure names in two C files? |
Structures are different |
Similar structures doing similar jobs - hence the same names. But they're not actually the same definitions - hence the warnings. |
Yes noted that now |
Will rename the structures to fix this. |
Just renaming is possibly not the best fix - the types are still public and could collide in future. If you really mean them to be local to that C++ file they should be wrapped in an anonymous namespace - the C++ equivalent of top-level I can feel this is something I'm going to be nitting about in review from now on - I always tended to point out people failing to put |
I believe so, as long as they are static. |
cc @ARMmbed/mbed-os-maintainers |
Description
When experimenting with LTO, the compiler has flagged a number of situations where the same struct occurs in multiple files, with different definitions.
The naming of these structs should be scoped to avoid collisions.
This may also have undesirable effects in builds where both definitions of the conflicting types are used.
See: https://travis-ci.org/ARMmbed/mbed-os/jobs/467813686
To test: Rebase #9080 on top of the fixes and verify that there are no "one definition rule" warnings.
Issue request type
The text was updated successfully, but these errors were encountered: