You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Global using types can conflict with downstream users #6323
These are not in the Assimp namespace and the names are generic enough that they will cause issues to downstream users that import the library and have structs with the same name.
An example of a downstream library that uses assimp and will be broken by this change is the Bullet physics library, that uses its own NodeArray type here. Exporting a global NodeArray will force the library to either rename their type or fail compilation going forward.
Proposed Solution
The new types should be namespaced to Assimp instead
A using directive can be placed at the top of a .cpp file (at file scope), or inside a class or function definition.
In general, avoid putting using directives in header files (*.h) because any file that includes that header will
bring everything in the namespace into scope, which can cause name hiding and name collision problems
that are very difficult to debug. Always use fully qualified names in a header file.
A good rule of thumb is that using-statements should not be placed anywhere where they might have an impact on
code in a different file. Nor should they be placed anywhere where another file’s code might be able to impact them.
More specifically, this means using-statements should not be used in header files, nor before an #include directive.
I fully agree with you and actually my first recommendation would be to just revert the change itself. Given how the types are used just a few times but in a lot of different files, moving the using directive from the header to the source file would cause a lot of duplication, pretty much defeating the original scope of the PR that was meant to be a cleanup, hence my second in order of preference of a "compromise" to encapsulate it in the namespace.
I'll open a PR to revert it then!
Activity
tellypresence commentedon Aug 13, 2025
@luca-della-vedova Thank you for the report; those
usingdirectives shouldn't be in that.hfile.General C++ advice is that
usingdirectives shouldn't be in header files, some references:luca-della-vedova commentedon Aug 13, 2025
Hi and thanks for the quick reply!
I fully agree with you and actually my first recommendation would be to just revert the change itself. Given how the types are used just a few times but in a lot of different files, moving the
usingdirective from the header to the source file would cause a lot of duplication, pretty much defeating the original scope of the PR that was meant to be a cleanup, hence my second in order of preference of a "compromise" to encapsulate it in the namespace.I'll open a PR to revert it then!
luca-della-vedova commentedon Aug 14, 2025
Opened reverting PR #6324