Skip to content

Using Unicode identifiers in C++ fails #14026

@jagot

Description

@jagot

Describe the bug

Repost of breathe-doc/breathe#1044, since I suspect the underlying issue is in Sphinx itself:

Thanks for this nice package!

I have attached a MWE: test-doc.tar.gz, as well as a minimal index.rst.

In short, using Unicode identifiers fails, as in this example:

/**
   @brief My very own struct.
 */
template<typename T>
struct MyStruct {
  T α; ///< A magic number
};

namespace my_namespace {
  /**
     @brief Print the value of `ξ`.

  @param ξ The value to be printed.
   */
  void my_fancy_function(int ξ) {
    std::cout << "ξ = " << ξ << std::endl;
  }
}

The error message I am getting:

/private/tmp/test-doc/index.rst:18: WARNING: Error in declarator or parameters-and-qualifiers
If pointer to member declarator:
  Invalid C++ declaration: Expected identifier in nested name. [error at 2]
    T α
    --^
If declarator-id:
  Invalid C++ declaration: Expected identifier in nested name. [error at 2]
    T α
    --^

/private/tmp/test-doc/index.rst:20: WARNING: doxygenfunction: Unable to resolve function "my_fancy_function" with arguments "None".
Candidate function could not be parsed. Parsing error is
Error when parsing function declaration.
If the function has no return type:
  Error in declarator or parameters-and-qualifiers
  Invalid C++ declaration: Expected identifier in nested name, got keyword: void [error at 4]
    void my_fancy_function (int ξ)
    ----^
If the function has a return type:
  Error in declarator or parameters-and-qualifiers
  If pointer to member declarator:
    Invalid C++ declaration: Expected '::' in pointer to member (function). [error at 23]
      void my_fancy_function (int ξ)
      -----------------------^
  If declarator-id:
    Invalid C++ declaration: Expecting "," or ")" in parameters-and-qualifiers, got "ξ". [error at 28]
      void my_fancy_function (int ξ)
      ----------------------------^ [docutils]

and the resulting output:

Image

Meanwhile, the Doxygen HTML output works fine:

Image

If I replace the Greek letters with Latin identifiers, the documentation builds correctly.

How to Reproduce

Simply run make in the extracted folder of the attached MWE test-doc.tar.gz

For an absolute minimum index.rst, that reproduces the error:

.. TestDoc documentation master file, created by
   sphinx-quickstart on Tue Nov  4 08:08:50 2025.
   You can adapt this file completely to your liking, but it should at least
   contain the root `toctree` directive.

TestDoc documentation
=====================

Add your content using ``reStructuredText`` syntax. See the
`reStructuredText <https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html>`_
documentation for details.


.. toctree::
   :maxdepth: 2
   :caption: Contents:

.. cpp:function:: void my_fancy_function(int ξ)

                  Print the value of ξ.

                  .. cpp:var:: ξ

                               The value to be printed.

.. cpp:struct:: template<typename T> MyStruct
                
                My very own struct
                
.. cpp:member:: T α
                
                A magic number

Environment Information

Platform:              darwin; (macOS-26.0.1-arm64-arm-64bit-Mach-O)
Python version:        3.14.0 (main, Oct  7 2025, 09:34:52) [Clang 17.0.0 (clang-1700.3.19.1)])
Python implementation: CPython
Sphinx version:        8.2.3
Docutils version:      0.21.2
Jinja2 version:        3.1.6
Pygments version:      2.19.2


The virtual environment was instantiated from the following `requirements.txt`:

sphinx>=8,<9
breathe
sphinxcontrib-bibtex
furo

Sphinx extensions

Only extension I use is "breathe".

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions