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 fails to generate constants if #defines are out of order #2597

Open
roypat opened this issue Aug 3, 2023 · 2 comments
Open

Bindgen fails to generate constants if #defines are out of order #2597

roypat opened this issue Aug 3, 2023 · 2 comments

Comments

@roypat
Copy link

roypat commented Aug 3, 2023

Input C/C++ Header

#define A B
#define B 1

Bindgen Invocation

bindgen input.h

Actual Results

/* automatically generated by rust-bindgen 0.66.1 */

pub const B: u32 = 1;

Expected Results

I expected

pub const A: u32 = 1;
pub const B: u32 = 1;

Both gcc and clang accept these kind of "out of order" definitions (as counter-intuitive as it is), and the linux kernel makes use of this in kvm.h, which is how we discovered this issue in rust-vmm/kvm-bindings#89

@pvdrz
Copy link
Contributor

pvdrz commented Aug 8, 2023

I think #2561 doesn't strictly fix this but it is a step in that direction iiuc (cc @reitermarkus).

If that's the case maybe this is a good enough reason to do this change, what do you think @emilio?

@reitermarkus
Copy link
Contributor

No, #2561 doesn't fix this, but #2369 which depends on #2561 will fix it.

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

3 participants