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

Doxygen only expands macro defined in header file once when referred multiple times #6856

Open
Jerry-Ma opened this issue Feb 24, 2019 · 7 comments

Comments

@Jerry-Ma
Copy link

With

ENABLE_PREPROCESSING   = YES
MACRO_EXPANSION        = YES

and the following code snippet:

// macro.h
#define meta_enum_class(Type, UnderlyingType, ...)\
    enum class Type : UnderlyingType { __VA_ARGS__}

// use1.h
#include "macro.h"
/** @enum Use1 */
meta_enum_class(Use1, int, a, b, c);

// use2.h
#include "macro.h"
/** @enum Use2 */
meta_enum_class(Use2, int, d, e, f);

Doxygen could not correctly expand both of the macro usage, which results in failure of showing documentation for Use2, or Use1, depending on which file is processed first.

Say, if use1.h is processed first, which doxygen correctly expand the macro there and produces documentation for enum Use1, then at the time it processes use2.h, the macro.h header is skipped so the meta_enum_class macro is not expanded, which is evident upon examining the output with -d preprocess:

Preprocessing /path/to/use2.h...
#include macro.h: already included! skipping...

Any suggestions on how to do this?

@albert-github
Copy link
Collaborator

albert-github commented Feb 24, 2019

I tried it with version 1.8.15 and didn't see a problem (maybe I looked at the wrong results).
I added to the files:

  • a \file statement to be sure the files are included
  • some documentation o the Use1 and Use2, now they only have a placeholder.

Which version of doxygen are you using?
Can you please attach a, small, self contained example (source+configuration file in a tar or zip) that allows us to reproduce the problem? Please don't add external links as they might not be persistent. In this case especially the Doxyfile is of importance.

@albert-github albert-github added the needinfo reported bug is incomplete, please add additional info label Feb 24, 2019
@Jerry-Ma
Copy link
Author

Jerry-Ma commented Feb 24, 2019

I am using Doxygen 1.8.14, installed via home brew on macOS 10.14. Here I am attaching the code that demonstrates the problem.

Please note the

INPUT = @CMAKE_CURRENT_SOURCE_DIR@/src/use1.h \
        @CMAKE_CURRENT_SOURCE_DIR@/src \
        @CMAKE_CURRENT_SOURCE_DIR@/docs

in Doxyfile.in, this causes Use1 in use1.h correctly documented while Use2 in use2.h not. Removing the first item will make both Use1 and Use2 un-documented, because the ordering of files is main.cpp, use1.h, then use2.h, where the macro expansion happens only once during processing main.cpp.

test_doxygen_macro_expansion.tar.gz

@albert-github albert-github added bug C/C++ and removed needinfo reported bug is incomplete, please add additional info labels Feb 25, 2019
albert-github added a commit to albert-github/doxygen that referenced this issue Feb 25, 2019
…once when referred multiple times

In case the include file is already is already in the global stack it should not be added to the global stack, but still be handled for the current file
@albert-github
Copy link
Collaborator

I've just pushed a proposed patch, pull request #6859

@Jerry-Ma
Copy link
Author

Jerry-Ma commented Feb 25, 2019

Thanks for working on that. I am looking forward to seeing it getting to the next release.

Just to get around the issue at the moment, I am using a macro PREDEFINED=DOXYGEN and the following:

#ifdef DOXYGEN
/**
 * @enum Use1
 *  ...docs...
 */
enum class Use1: int {a, b, c};
#else
meta_enum_class(Use1, int, a, b, c);
#endif

doxygen added a commit that referenced this issue Mar 20, 2019
issue #6856 Doxygen only expands macro defined in header file once when referred multiple times
@albert-github
Copy link
Collaborator

Code has been integrated in master on github (please don't close the issue as this will be done at the moment of a release).

@albert-github albert-github added the fixed but not released Bug is fixed in github, but still needs to make its way to an official release label Mar 21, 2019
@albert-github
Copy link
Collaborator

The mentioned (and currently) merged patch has some negative effects (hanging processes), see #6897.

doxygen added a commit that referenced this issue Mar 28, 2019
doxygen added a commit that referenced this issue Mar 29, 2019
Revert "issue #6856 Doxygen only expands macro defined in header file once when referred multiple times"
@albert-github albert-github removed the fixed but not released Bug is fixed in github, but still needs to make its way to an official release label Mar 29, 2019
@albert-github
Copy link
Collaborator

Unfortunately patch had to be reverted by #6903 due to #6897.

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

No branches or pull requests

2 participants