Skip to content

Commit

Permalink
Support unnamed namespaces, closes hsutter#283
Browse files Browse the repository at this point in the history
The syntax is:

    _ : namespace = /*etc.*/
  • Loading branch information
hsutter authored and zaucy committed Dec 5, 2023
1 parent 48df7f5 commit 7d47c53
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion source/cppfront.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4268,7 +4268,15 @@ class cppfront
if (n.is_namespace())
{
printer.print_cpp2("namespace ", n.position());
emit(*n.identifier);

// "_" is the anonymous namespace, which is just whitespace in Cpp1
if (auto tok = n.identifier->get_token();
tok
&& *tok != "_"
)
{
emit(*n.identifier);
}

assert(
n.initializer
Expand Down

0 comments on commit 7d47c53

Please sign in to comment.