Skip to content

Avoid using namespace in Header Files  #114

Open

Description

@TimmRuppert

The use of using namespace xyz in header files is generally discouraged. In this project, it is currently present in the example files:

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:

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.

Activity

  1. added
    feature requestProposals which enhance the interface or add additional features.
    on Oct 11, 2024
  2. self-assigned this
    on Oct 11, 2024
  3. added
    qualityQuality improvements.
    and removed
    feature requestProposals which enhance the interface or add additional features.
    on Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

qualityQuality improvements.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions