Skip to content

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

@roypat

Description

@roypat

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions