6
votes

I'm using Doxygen 1.8.5 and having the same exact problem as in the following question, only the language is C and the enums are in the C files:

Doxygen C# XML comments: multiply enum's with same name and different scope got merged?

According to https://bugzilla.gnome.org/show_bug.cgi?id=522193 it was fixed in 1.6.0, but I'm guessing Doxygen isn't treating different C files as having different namespaces.

The enums in question pertain only to each specific file, but are called the same name because they are used for the same purpose in that file (for flags used to track status information about that module, for example). The C compiler has no problem with this, but Doxygen combines them.

Example:

file1.c

enum status_flags {
    sfACTIVE,
    sfSHUTDOWN,
    sfWARNING,
};

file2.c

enum status_flags {
    sfSTANDBY,
    sfSCREEN_OWNED,
};

The doxygen file will generate a single blob of both enums combined, including the comments for each member, and reference them in the documentation for both files.

enum status_flags

Enumerator

sfACTIVE

sfSHUTDOWN

sfWARNING

sfSTANDBY

sfSCREEN_OWNED

Definition at line 42 of file file1.c.

and

enum status_flags

Enumerator

sfACTIVE

sfSHUTDOWN

sfWARNING

sfSTANDBY

sfSCREEN_OWNED

Definition at line 65 of file file2.c.

I've tried making each file a member of its own @addtogroup, and I've made sure each file has an @file at the top, but it's still mixing all of these enums together which are supposed to be private to that particular C file. It would be a bit of a pain if I were forced to rename each of these enums, as there are dozens of applications in the code which all follow a similar format and use private enums of the same name with different flags. The compiler is perfectly happy to work with them.

Any ideas?

1
Did you work this out? I'm having the same problem; my enums are even in separate namespaces, but somehow they get merged together.csiz

1 Answers

0
votes

Anonymous typedef enum also have this same issue,

typedef enum {
    sfACTIVE,
    sfSHUTDOWN,
    sfWARNING
} status_flags;

results in the combining issue, but Doxygen appears to give priority to the enumeration, so combining does not happen when you do this:

typedef enum status_flags_f1 {
    sfACTIVE,
    sfSHUTDOWN,
    sfWARNING
} status_flags;

typedef enum status_flags_f2 {
    sfSTANDBY,
    sfSCREEN_OWNED
} status_flags;

This only works if TYPEDEF_HIDES_STRUCT is set to NO in the Doxyfile configuration file, which is the default.