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

Bindgen does not keep documentation of #define constants #2756

Open
HadrienG2 opened this issue Feb 12, 2024 · 1 comment
Open

Bindgen does not keep documentation of #define constants #2756

HadrienG2 opened this issue Feb 12, 2024 · 1 comment

Comments

@HadrienG2
Copy link

HadrienG2 commented Feb 12, 2024

C libraries commonly (ab)use defines to represent compilation constants. Therefore, the Doxygen documentation of these defines can contain valuable information and should be kept by bindgen, but alas it currently does not happen.

I am well aware that because defines are handled by the preprocessor, solving this may be harder than it sounds...

Input C/C++ Header

/** \brief Current component and plugin ABI version (see hwloc/plugins.h) */
#define HWLOC_COMPONENT_ABI 7

Bindgen Invocation

$ bindgen input.h

Actual Results

Bindgen discards the docs:

pub const HWLOC_COMPONENT_ABI: u32 = 7;

Expected Results

Bindgen keeps the docs around:

#[doc = " \brief Current component and plugin ABI version (see hwloc/plugins.h) "]
pub const HWLOC_COMPONENT_ABI: u32 = 7;
@pvdrz
Copy link
Contributor

pvdrz commented Apr 3, 2024

You are right, solving it seems to be harder than it looks.

I tried to parse the comment when the clang cursor is under a macro definition and we get null. There doesn't seem to be any way to fetch this info from the clang API: https://clang.llvm.org/doxygen/classclang_1_1MacroDefinition.html. MacroInfo doesn't have any info regarding documentation or comments.

So it seems this is not something we can do unless someone makes a custom parser for it which sounds like a lot of work.

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

2 participants