Skip to content

AssertionError when using anonymous namespaces #1021

@IcarusCoding

Description

@IcarusCoding

When using anonymous namespaces like:

namespace {
constexpr std::string_view test{"test"};
}

I get the following error:

[...] WARNING: Error in type declaration.
If typedef-like declaration:
  Type must be either just a name or a typedef-like declaration.
  If just a name:
    Error in declarator or parameters-and-qualifiers
    Invalid C++ declaration: Expected identifier in nested name. [error at 0]
      
      ^
  If typedef-like declaration:
    Invalid C++ declaration: Expected identifier in nested name. [error at 0]
      
      ^
If type alias or template alias:
  Invalid C++ declaration: Expected identifier in nested name. [error at 0]
    
    ^

Exception occurred:
  File "/usr/lib/python3/dist-packages/breathe/renderer/sphinxrenderer.py", line 710, in handle_declaration
    assert isinstance(n, addnodes.desc_sig_keyword)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

The following works though:

namespace test {
namespace {
constexpr std::string_view test{"test"};
}
}

Environment:

Platform:              linux; (Linux-6.8.0-51-generic-x86_64-with-glibc2.39)
Python version:        3.12.3 (main, Jan 17 2025, 18:03:48) [GCC 13.3.0])
Python implementation: CPython
Sphinx version:        7.2.6
Docutils version:      0.20.1
Jinja2 version:        3.1.2
Pygments version:      2.17.2
Breathe version:       4.35.0
Doxygen version:       1.9.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions