Skip to content

treewide: Move private types and code into anonymous namespaces #13688

Merged
Mic92 merged 3 commits intoNixOS:masterfrom
xokdvium:odr-toplevel-types
Aug 5, 2025
Merged

treewide: Move private types and code into anonymous namespaces #13688
Mic92 merged 3 commits intoNixOS:masterfrom
xokdvium:odr-toplevel-types

Conversation

@xokdvium
Copy link
Contributor

@xokdvium xokdvium commented Aug 4, 2025

Motivation

Having a class with a generic name like State in the nix namespace is asking
for ODR trouble, since it would blow up if another such class were to appear.
A lot of other library classes can be moved to anonymous namespaces. We could
start being a bit more principled about this. Maybe clang-tidy tooling can help
with this in the future?

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

Having a State class in the nix namespace is asking
for ODR trouble. This class is already private to the
translation unit, let's move it into an anonymous namespace.
Same as previous commit. This really should not be a part of
the `nix` namespace. Otherwise the doxygen documentation is
really confusing.
This code should be private to the corresponding translation units.
@github-actions github-actions bot added the new-cli Relating to the "nix" command label Aug 4, 2025
@Mic92 Mic92 merged commit 4a7285c into NixOS:master Aug 5, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-cli Relating to the "nix" command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants