Skip to content

handling the same names of unnamed enum member and define #1242

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

Closed
Dushistov opened this issue Jan 30, 2018 · 3 comments
Closed

handling the same names of unnamed enum member and define #1242

Dushistov opened this issue Jan 30, 2018 · 3 comments

Comments

@Dushistov
Copy link
Contributor

Dushistov commented Jan 30, 2018

Input C/C++ Header

This is reduced test case. I created it based on headers of glibc 2.26.
You can see in comments from which standard headers I got C code.

//netinet/in.h
enum
  {
IPPORT_RESERVED = 1024,
};
//netdb.h
# define IPPORT_RESERVED        1024

Bindgen Invocation

$ ~/bin/bindgen.sh --no-layout-tests --no-rustfmt-bindings test.h  | ~/bin/rustfmt-nightly.sh

Actual Results

/* automatically generated by rust-bindgen */

pub const IPPORT_RESERVED: ::std::os::raw::c_uint = 1024;
pub const IPPORT_RESERVED: _bindgen_ty_1 = 1024;
pub type _bindgen_ty_1 = u32;

as result compile time error from rustc:

the name `IPPORT_RESERVED` is defined multiple times

Expected Results

I'm creating bindging for 3rdparty library, and it's headers indirectly include both headers (netdb.h and netinet/in.h).
It would be nice to add some kind of mechanizm to prevent such kind of errors
without need to edit glibc headers or 3rdparty library's headers.

@fitzgen
Copy link
Member

fitzgen commented Jan 30, 2018

Thanks for filing an issue!

@emilio
Copy link
Contributor

emilio commented Jan 30, 2018

Closing as a dupe of #687.

@emilio emilio closed this as completed Jan 30, 2018
@trsh
Copy link

trsh commented May 10, 2018

What is the solution? Also getting > IPPORT_RESERVED must be defined only once in the value namespace of this module

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

4 participants