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

Ref points to typedef instead of typedef'd enum #9359

Open
szanni opened this issue May 27, 2022 · 3 comments
Open

Ref points to typedef instead of typedef'd enum #9359

szanni opened this issue May 27, 2022 · 3 comments

Comments

@szanni
Copy link

szanni commented May 27, 2022

Describe the bug
When using the \ref command to link to an enum it will create a link to the typedef instead of the the enum itself.

Expected behavior
The link created by the \ref command should point to the documented enum, like links in the type signature do.

Screenshots
As highlighted in the screenshot: the \ref foo points to the typedef, whereas the type signature correctly points to the enum.
bug

To Reproduce
Doxygen the following code or the attached example. Check the HTML documentation. The link created by \ref foo will point to the typedef, the type signature will point to the enum. Both should point to the documented enum.

/**
 * Docs for foo.
 *
 * @enum foo
 */
typedef enum foo foo;
enum foo {
	int member; //!< Member doc
};

/**
 * Some function.
 *
 * @param f Parameter of type @ref foo
 */
void func(foo f);

Placing the enum documentation directly above the enum itself does not change anything.

bug-enum-typedef-link-example.tar.gz

Version
1.9.3 - Arch Linux x86_64 package (1.9.3-1).

@doxygen
Copy link
Owner

doxygen commented Jun 1, 2022

A simple 'fix' would be to use:

typedef enum foo foo;
/**
 * Docs for foo.
 */
enum foo {
	int member; //!< Member doc
};

/**
 * Some function.
 *
 * @param f Parameter of type @ref foo
 */
void func(foo f);

Any reason why the documentation needs to be in front of the typedef if you actually want to document the enum?

@enum, @fn, @var and @typedef are currently just aliases, each can point to any member with the given name, hence the reference to the typedef.

@szanni
Copy link
Author

szanni commented Jun 1, 2022

A simple 'fix' would be to use:

typedef enum foo foo;
/**
 * Docs for foo.
 */
enum foo {
	int member; //!< Member doc
};

/**
 * Some function.
 *
 * @param f Parameter of type @ref foo
 */
void func(foo f);

Did you test this? The 'fix' exhibits the same bug as the code I provided. I tested this already as I was trying to state by my comment:

Placing the enum documentation directly above the enum itself does not change anything.

Any reason why the documentation needs to be in front of the typedef if you actually want to document the enum?

Sadly yes. The actual code goes something like this:

#define _UI_ENUM(s) typedef unsigned int s; enum
/**
 * Docs for foo.
 *
 * @enum foo
 */
_UI_ENUM(foo) {
    int member; //!< Member doc
};

/**
 * Some function.
 *
 * @param f Parameter of type @ref foo
 */
void func(foo f);

Defining the type as unsigned is done for future ABI compatability of the library.

We then redefine "_UI_ENUM(s)=typedef enum s s; enum s" in Doxygen's PREDEFINED list.

Removing the typedef for Doxygen gives the desired results with regards to the generated links, but is incorrect code. It currently seems to work, as Doxygen uses the C++ parser and even clang seems to ignore the extern "C"? It seems very brittle though.

@luketpeterson
Copy link

@szanni For me personally, the "TYPEDEF_HIDES_STRUCT" feature was the answer. This avoided the problem entirely by eliminating the duplicate entry. I don't know if this will work for you but I figured I'd mention it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants