Fix callback_info ODR violation
Resolves an ODR violation related to the callback_info struct when using LTO.
This commit fixes an ODR (One Definition Rule) violation that occurred due to a naming conflict with the callback_info struct. The struct, defined in plugin.cc, had the same name as another struct in plugin.cc itself (or possibly a different file included transitively). To resolve this, the callback_info struct is now placed within an anonymous namespace, ensuring its uniqueness and preventing ODR issues, particularly when compiling with Link-Time Optimization (LTO).
In Details
The callback_info struct in plugin.cc clashed with another entity of the same name, causing an ODR violation when LTO was enabled. Placing the struct within an anonymous namespace, as suggested by Drea Pinski, ensures that its linkage is internal to the translation unit, thereby resolving the ODR issue without affecting the struct's intended usage.
- ODR
- One Definition Rule, a C++ rule stating that an entity can have at most one definition in a program. Violations can lead to link-time or runtime errors, especially with LTO.
- LTO
- Link-Time Optimization, a compilation technique where optimization is performed across multiple source files at link time, allowing for more aggressive optimizations but increasing the risk of ODR violations.
- Anonymous Namespace
- In C++, a namespace declared without a name. Entities declared within it have internal linkage, meaning they are only visible within the current translation unit (source file).
- plugin.cc
- A GCC source file that likely handles the compiler's plugin API, allowing external tools to extend GCC's functionality.