Closed
Description
Input C/C++ Header
enum {
A =
#define A 0
A,
} anenum;
Bindgen Invokation
bindgen::Builder::default()
.header("input.h")
.generate()
.unwrap()
Actual Results
Fresh bindgen v0.23.1 Compiling math_dot_h v0.1.0 (file:///home/def/p/rust/math_dot_h)
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`
error[E0428]: a value named `A` has already been defined in this module
--> /home/def/p/rust/math_dot_h/target/debug/build/math_dot_h-7f0a85db403a8610/out/bindings.rs:4:1
|
3 | pub const A: ::std::os::raw::c_uint = 0;
| ---------------------------------------- previous definition of `A` here
4 | pub const A: _bindgen_ty_1 = _bindgen_ty_1::A;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `A` already defined
error: aborting due to previous error
error: Could not compile `math_dot_h`.
Caused by:
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)
Expected Results
No compilation error, both the enum and the define have their own name space.
This is problematic IRL because math.h
uses this construct to define FP_*
constants:
https://sourceware.org/git/?p=glibc.git;a=blob;f=math/math.h;h=cfaed0ed98013830421afdf1ba6f13c01702831d;hb=HEAD#l318
enum { FP_NAN = # define FP_NAN 0 FP_NAN, FP_INFINITE = # define FP_INFINITE 1 FP_INFINITE,
FP_ZERO =
# define FP_ZERO 2
FP_ZERO,
FP_SUBNORMAL =
# define FP_SUBNORMAL 3
FP_SUBNORMAL,
FP_NORMAL =
# define FP_NORMAL 4
FP_NORMAL
};
RUST_LOG=bindgen
Output
Compiling math_dot_h v0.1.0 (file:///home/def/p/rust/math_dot_h)
error[E0428]: a value named `A` has already been defined in this module
--> /home/def/p/rust/math_dot_h/target/debug/build/math_dot_h-7f0a85db403a8610/out/bindings.rs:4:1
|
3 | pub const A: ::std::os::raw::c_uint = 0;
| ---------------------------------------- previous definition of `A` here
4 | pub const A: _bindgen_ty_1 = _bindgen_ty_1::A;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `A` already defined
error: aborting due to previous error
error: Could not compile `math_dot_h`.
To learn more, run the command again with --verbose.