{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang-nursery/rust-bindgen/issues/687","repository_url":"https://api.github.com/repos/rust-lang-nursery/rust-bindgen","labels_url":"https://api.github.com/repos/rust-lang-nursery/rust-bindgen/issues/687/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang-nursery/rust-bindgen/issues/687/comments","events_url":"https://api.github.com/repos/rust-lang-nursery/rust-bindgen/issues/687/events","html_url":"https://github.com/rust-lang-nursery/rust-bindgen/issues/687","id":226121836,"number":687,"title":"enum and define with the same name collide","user":{"login":"deweerdt","id":5094,"avatar_url":"https://avatars1.githubusercontent.com/u/5094?v=4","gravatar_id":"","url":"https://api.github.com/users/deweerdt","html_url":"https://github.com/deweerdt","followers_url":"https://api.github.com/users/deweerdt/followers","following_url":"https://api.github.com/users/deweerdt/following{/other_user}","gists_url":"https://api.github.com/users/deweerdt/gists{/gist_id}","starred_url":"https://api.github.com/users/deweerdt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deweerdt/subscriptions","organizations_url":"https://api.github.com/users/deweerdt/orgs","repos_url":"https://api.github.com/users/deweerdt/repos","events_url":"https://api.github.com/users/deweerdt/events{/privacy}","received_events_url":"https://api.github.com/users/deweerdt/received_events","type":"User","site_admin":false},"labels":[{"id":396826309,"url":"https://api.github.com/repos/rust-lang-nursery/rust-bindgen/labels/bug","name":"bug","color":"ee0701","default":true},{"id":555559489,"url":"https://api.github.com/repos/rust-lang-nursery/rust-bindgen/labels/I-bogus-codegen","name":"I-bogus-codegen","color":"c2e0c6","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2017-05-03T21:34:59Z","updated_at":"2017-12-08T18:19:24Z","closed_at":null,"author_association":"NONE","body":"### Input C/C++ Header\r\n\r\n```C\r\nenum {\r\n        A =\r\n#define A 0\r\n                A,\r\n} anenum;\r\n```\r\n\r\n### Bindgen Invokation\r\n\r\n<!-- Place either the `bindgen::Builder` or the command line flags used here. -->\r\n\r\n```Rust\r\nbindgen::Builder::default()\r\n    .header(\"input.h\")\r\n    .generate()\r\n    .unwrap()\r\n```\r\n\r\n\r\n### Actual Results\r\n\r\n\r\n```\r\n       Fresh bindgen v0.23.1                                                                                                                                                                                                                                                                                                        Compiling math_dot_h v0.1.0 (file:///home/def/p/rust/math_dot_h)\r\n     Running `rustc --crate-name math_dot_h src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=93892b9e7e7b815c -C extra-filename=-93892b9e7e7b815c --out-dir /home/def/p/rust/math_dot_h/target/debug/deps -L dependency=/home/def/p/rust/math_dot_h/target/debug/deps`\r\nerror[E0428]: a value named `A` has already been defined in this module\r\n --> /home/def/p/rust/math_dot_h/target/debug/build/math_dot_h-7f0a85db403a8610/out/bindings.rs:4:1\r\n  |\r\n3 | pub const A: ::std::os::raw::c_uint = 0;\r\n  | ---------------------------------------- previous definition of `A` here\r\n4 | pub const A: _bindgen_ty_1 = _bindgen_ty_1::A;\r\n  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `A` already defined\r\n\r\nerror: aborting due to previous error\r\n\r\nerror: Could not compile `math_dot_h`.\r\n\r\nCaused by:\r\n  process didn't exit successfully: `rustc --crate-name math_dot_h src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=93892b9e7e7b815c -C extra-filename=-93892b9e7e7b815c --out-dir /home/def/p/rust/math_dot_h/target/debug/deps -L dependency=/home/def/p/rust/math_dot_h/target/debug/deps` (exit code: 101)\r\n```\r\n\r\n### Expected Results\r\n\r\nNo compilation error, both the enum and the define have their own name space.\r\n\r\nThis is problematic IRL because `math.h` uses this construct to define `FP_*` constants:\r\nhttps://sourceware.org/git/?p=glibc.git;a=blob;f=math/math.h;h=cfaed0ed98013830421afdf1ba6f13c01702831d;hb=HEAD#l318\r\n\r\n```c\r\nenum                                                                                                                                                                                                                                                                                                                               {                                                                                                                                                                                                                                                                                                                                  FP_NAN =                                                                                                                                                                                                                                                                                                                     # define FP_NAN 0                                                                                                                                                                                                                                                                                                                      FP_NAN,                                                                                                                                                                                                                                                                                                                        FP_INFINITE =                                                                                                                                                                                                                                                                                                                # define FP_INFINITE 1                                                                                                                                                                                                                                                                                                                 FP_INFINITE,\r\n    FP_ZERO =\r\n# define FP_ZERO 2\r\n      FP_ZERO,\r\n    FP_SUBNORMAL =\r\n# define FP_SUBNORMAL 3\r\n      FP_SUBNORMAL,\r\n    FP_NORMAL =\r\n# define FP_NORMAL 4\r\n      FP_NORMAL\r\n  };\r\n```\r\n\r\n### `RUST_LOG=bindgen` Output\r\n\r\n<details>\r\n\r\n```\r\n   Compiling math_dot_h v0.1.0 (file:///home/def/p/rust/math_dot_h)\r\nerror[E0428]: a value named `A` has already been defined in this module\r\n --> /home/def/p/rust/math_dot_h/target/debug/build/math_dot_h-7f0a85db403a8610/out/bindings.rs:4:1\r\n  |\r\n3 | pub const A: ::std::os::raw::c_uint = 0;\r\n  | ---------------------------------------- previous definition of `A` here\r\n4 | pub const A: _bindgen_ty_1 = _bindgen_ty_1::A;\r\n  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `A` already defined\r\n\r\nerror: aborting due to previous error\r\n\r\nerror: Could not compile `math_dot_h`.\r\n\r\nTo learn more, run the command again with --verbose.\r\n```\r\n\r\n</details>\r\n"},"comment":{"url":"https://api.github.com/repos/rust-lang-nursery/rust-bindgen/issues/comments/350334559","html_url":"https://github.com/rust-lang-nursery/rust-bindgen/issues/687#issuecomment-350334559","issue_url":"https://api.github.com/repos/rust-lang-nursery/rust-bindgen/issues/687","id":350334559,"user":{"login":"spacekookie","id":7669898,"avatar_url":"https://avatars0.githubusercontent.com/u/7669898?v=4","gravatar_id":"","url":"https://api.github.com/users/spacekookie","html_url":"https://github.com/spacekookie","followers_url":"https://api.github.com/users/spacekookie/followers","following_url":"https://api.github.com/users/spacekookie/following{/other_user}","gists_url":"https://api.github.com/users/spacekookie/gists{/gist_id}","starred_url":"https://api.github.com/users/spacekookie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spacekookie/subscriptions","organizations_url":"https://api.github.com/users/spacekookie/orgs","repos_url":"https://api.github.com/users/spacekookie/repos","events_url":"https://api.github.com/users/spacekookie/events{/privacy}","received_events_url":"https://api.github.com/users/spacekookie/received_events","type":"User","site_admin":false},"created_at":"2017-12-08T18:19:24Z","updated_at":"2017-12-08T18:19:24Z","author_association":"NONE","body":"Hey @fitzgen, I mean...I'd love to have a try at fixing this though I've only been writing Rust for ~2 months now and I'm rather green, especially when it comes to _large_ Rust projects. If you're offering to mentor though, maybe get in touch with me via [twitter](https://twitter.com/spacekookie) or [e-mail](mailto:kookie@spacekookie.de)?"}}
{"actor":{"display_login":"spacekookie"}}