Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid definition for a C++ function taking an array reference as an argument #1753

Closed
vitaut opened this issue Mar 2, 2015 · 7 comments
Closed

Comments

@vitaut
Copy link
Contributor

vitaut commented Mar 2, 2015

I get the error

index.rst:1: WARNING: Invalid definition: expected identifier [error at 1]
  f(int (&array)[10])
  -^

on the following Sphinx code:

.. cpp:function:: f(int (&array)[10])
@lehmannro
Copy link
Contributor

No, expected identifier is unrelated to fmtlib/fmt#125: This complaint is about the missing return type. void f(int &array[10]) works fine. The underlying issue with template declarations should be covered in #1314.

@vitaut
Copy link
Contributor Author

vitaut commented Mar 2, 2015

I get an error even with return value on Sphinx 1.3b3:

index.rst:1: WARNING: Invalid definition: Expecting "," or ")" in parameters_and_qualifiers, got "(". [error at 11]
  void f(int (&array)[10])
  -----------^

@vitaut
Copy link
Contributor Author

vitaut commented Mar 2, 2015

Please note that the declaration is void f(int (&array)[10]) and not void f(int &array[10]) as an array of references is not valid in C++.

@lehmannro
Copy link
Contributor

Can you drop the surrounding braces around &array?

@vitaut
Copy link
Contributor Author

vitaut commented Mar 2, 2015

Can you drop the surrounding braces around &array?

Unfortunately not, because it changes semantics.

@jakobandersen
Copy link
Contributor

Yes, this is indeed a bug. Furthermore, the error is not accurate. In this case it should be
Invalid definition: Expecting "," or ")" in parameters_and_qualifiers, got "(". as you indicate.
I'm working on a fix.

@vitaut
Copy link
Contributor Author

vitaut commented Mar 2, 2015

Thanks, @jakobandersen.

jakobandersen added a commit to jakobandersen/sphinx that referenced this issue Mar 5, 2015
Support `( ptr-declarator )`, e.g., `int (*f)(double)`, or
`int (&a)[42]`.
Still missing check for compatibility with old id generation scheme.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants