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
Using using namespace in header files is generally considered bad practice because it can lead to namespace pollution and unexpected name conflicts. When you include a header file that uses using namespace, it brings all the names from the specified namespace into the global namespace of any file that includes it. This can cause name collisions and make the code harder to understand and maintain. At the moment of writing this issue, we have 183 using directives in 149 files. Since this is a header-only project, I'd say we have this issue in almost 60% of files.
Why This Is a Problem
Namespace Pollution: All names from the "used" namespaces are brought into the global namespace, which can lead to unintended name clashes. Code Maintainability: It becomes difficult to track where certain names are coming from, making the code harder to read and maintain. Potential Conflicts: If another header file or source file includes the same header and defines names that conflict with those in the namespace that was included using using namespace directive, it can lead to compilation errors or unexpected behavior.
Solution
Remove using namespace directives: Remove the using namespace directives from all of the header files and fully qualify the names from namespaces where they are used.
The text was updated successfully, but these errors were encountered:
I'm doing tenstorrent/tt-metal#7736, would you like it if I voluntarily remove using namespace sfpi as well on the ckernel_sfpu_*.h files? The OPs work without it
Description
Using using namespace in header files is generally considered bad practice because it can lead to namespace pollution and unexpected name conflicts. When you include a header file that uses using namespace, it brings all the names from the specified namespace into the global namespace of any file that includes it. This can cause name collisions and make the code harder to understand and maintain. At the moment of writing this issue, we have 183 using directives in 149 files. Since this is a header-only project, I'd say we have this issue in almost 60% of files.
Why This Is a Problem
Namespace Pollution: All names from the "used" namespaces are brought into the global namespace, which can lead to unintended name clashes.
Code Maintainability: It becomes difficult to track where certain names are coming from, making the code harder to read and maintain.
Potential Conflicts: If another header file or source file includes the same header and defines names that conflict with those in the namespace that was included using
using namespace
directive, it can lead to compilation errors or unexpected behavior.Solution
Remove using namespace directives: Remove the using namespace directives from all of the header files and fully qualify the names from namespaces where they are used.
The text was updated successfully, but these errors were encountered: