-
Notifications
You must be signed in to change notification settings - Fork 736
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Multiple definitions when a pointer gets typedef’d to the same name as a struct #2227
Comments
We hit this with Linux kernel code like https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/include/linux/maple_tree.h#n75. I think providing a customizable prefix/suffix or moving the |
I have a potential fix for this but I have a tiny confusion about C semantics here. Let's say we have this typedef const struct foo {
void *bar;
} *foo_ptr;
struct foo returns_struct();
foo_ptr returns_ptr(); If now we remove the typedef const struct foo {
void *bar;
} *foo;
struct foo returns_struct();
foo returns_ptr(); so, neither |
The struct ( By the way, the Maple tree removed the problematic |
Input C/C++ Header
Bindgen Invocation
Actual Results
and/or
Expected Results
I’m not quite sure, as the issue is that
struct *
and*
are two “namespaces” in C, and not in C++ or Rust. One solution would be to rename either the pointer typedef or the struct, another would be to not include the pointer typedef at all (but then people might get confused why it isn’t present, so perhaps emit a warning as well?), or at least reject the input file altogether as the result won’t be well-formed anyway.The project in question uses this hack when built under C++, so for my usecase I could
#define __cplusplus
in order to run bindgen in C++ mode:The text was updated successfully, but these errors were encountered: