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

Declaring a new class as the result type of a function confuses doxygen (Origin: bugzilla #621780) #3805

doxygen opened this Issue Jul 2, 2018 · 0 comments


None yet
1 participant

doxygen commented Jul 2, 2018

status NEW severity normal in component general for ---
Reported in version 1.7.1 on platform Other
Assigned to: Dimitri van Heesch

Original attachment names and IDs:

On 2010-06-16 13:22:39 +0000, Timothy Madden wrote:

Created attachment 163820
Sample source code to illustrate the problem

When I declare a new class as the result type of a function, doxygen only sees the class and it treats content of the following function body as global-level declarations.

On 2010-06-16 13:24:44 +0000, Timothy Madden wrote:

Created attachment 163821
Generated documentation page

On 2010-06-17 12:54:45 +0000, Dimitri van Heesch wrote:

Hi Timothy,

This doesn't look like valid C++ to me, gcc seems to agree and says:

> gcc -c test.cpp 
test.cpp:6: error: new types may not be defined in a return type
test.cpp:6: note: (perhaps a semicolon is missing after the definition of �Coord�)

Why not use the following?
struct Coord
  int a;
  float f;
Coord GetLastCoord()
  Coord c;

  c.a = 0;
  c.f = 2.7f;

  return c;

On 2010-06-22 13:30:45 +0000, Timothy Madden wrote:

Created attachment 164308
example C code to reproduce the problem

C allows declaring a function with a new declared type as the function return type.
Also Visual Studio allows this in C++

On 2010-06-22 13:34:16 +0000, Timothy Madden wrote:

This is valid C code, though, as the 2003 C++ standard says (C1.6 Clause 8).

The C standard only says "A function declarator shall not specify a return type that is a function type or an array type."

So never mind my .cpp extension, this is C code (I made a new attachment), and gcc -c FuncStruct.c compiles successfully. 

So maybe this could still be fixed (for both C and C++ if possible) ?

In C++ they say they removed the feature because C++ relies on name equivalence, while C relies on structural equivalence. Despite that, Microsoft Visual Studio compiles such code in C++ without a problem or a warning.

On 2010-06-22 14:29:15 +0000, Dimitri van Heesch wrote:

Fair enough. I'll add this to doxygen's parsing capabilities.

On 2010-06-25 11:49:00 +0000, Dimitri van Heesch wrote:

This bug was previously marked ASSIGNED, which means it should be fixed in
doxygen version 1.7.1. Please verify if this is indeed the case. Reopen the
bug if you think it is not fixed and please include any additional information
that you think can be relevant.

On 2010-06-25 12:00:49 +0000, Timothy Madden wrote:

Doxygen now sees the structure members as global-level variables (the sample code is C++, but the same behavior happens for both C and C++).

Look for variables in the File Refrence in the attached documentation generated.

On 2010-06-25 12:01:32 +0000, Timothy Madden wrote:

Created attachment 164611
Doxyfile for v 1.7.1

On 2010-06-25 12:02:02 +0000, Timothy Madden wrote:

Created attachment 164612
.cpp source file

On 2010-06-25 12:02:39 +0000, Timothy Madden wrote:

Created attachment 164613
Generated documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment