GNOME Bugzilla – Bug 621780
Declaring a new class as the result type of a function confuses doxygen
Last modified: 2018-07-30 10:56:47 UTC
Created attachment 163820 [details] 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.
Created attachment 163821 [details] Generated documentation page
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; } ----------------------
Created attachment 164308 [details] 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++
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.
Fair enough. I'll add this to doxygen's parsing capabilities.
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.
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.
Created attachment 164611 [details] Doxyfile for v 1.7.1
Created attachment 164612 [details] .cpp source file
Created attachment 164613 [details] Generated documentation
As discussed in https://github.com/doxygen/doxygen/pull/734 , Doxygen has moved its issue tracking to https://github.com/doxygen/doxygen/issues All Doxygen tickets in GNOME Bugzilla have been migrated to Github. You can subscribe and participate in the new ticket in Github. You can find the corresponding Github ticket by searching for its Bugzilla ID (number) in Github. Hence I am closing this GNOME Bugzilla ticket. Please use the corresponding ticket in Github instead. Thanks a lot!