-
Notifications
You must be signed in to change notification settings - Fork 18
Description
The use of using namespace xyz
in header files is generally discouraged. In this project, it is currently present in the example files:
using namespace std; using namespace std;
Including using namespace in a header file can lead to unintended namespace pollution throughout the entire codebase, or even affect other projects that include the header. This practice can cause naming conflicts, such as having the same function defined more than once in the global namespace, leading to hard-to-debug issues.
Other people are way better at explaining this than I am:
- https://stackoverflow.com/questions/1452721/whats-the-problem-with-using-namespace-std
- https://www.geeksforgeeks.org/using-namespace-std-considered-bad-practice/
While the affected files are only examples, they may be used as templates by others. For instance, all OSMP-related functions in openMSL appear to be based on this code. This makes it important to ensure that best practices are followed, even in example code.
Suggested Fix
Remove the using namespace directive from the header files and, if necessary, use fully qualified names or place the directive within implementation files.