Skip to content

Dyn keyword is not escaped. #1946

@pronebird

Description

@pronebird

Input C/C++ Header

struct pf_addr_wrap {
	union {
		struct {
			struct pf_addr		 addr;
			struct pf_addr		 mask;
		}			 a;
		char			 ifname[IFNAMSIZ];
		char			 tblname[PF_TABLE_NAME_SIZE];
		char			 rtlabelname[RTLABEL_LEN];
		u_int32_t		 rtlabel;
	}			 v;
	union {
#ifdef KERNEL
		struct pfi_dynaddr	*dyn	__attribute__((aligned(8)));
		struct pfr_ktable	*tbl	__attribute__((aligned(8)));
#else /* !KERNEL */
		void			*dyn	__attribute__((aligned(8)));
		void			*tbl	__attribute__((aligned(8)));
#endif /* !KERNEL */
		int			 dyncnt __attribute__((aligned(8)));
		int			 tblcnt __attribute__((aligned(8)));
	}			 p __attribute__((aligned(8)));
	u_int8_t		 type;		/* PF_ADDR_* */
	u_int8_t		 iflags;	/* PFI_AFLAG_* */
};

Bindgen Invocation

bindgen::Builder::default()
    .header("input.h")
    .generate()
    .unwrap()

or

$ bindgen input.h --whatever --flags

Actual Results

error: expected identifier, found keyword `dyn`
   --> src/ffi/pfvar.rs:581:9
    |
581 |     pub dyn: *mut ::std::os::raw::c_void,
    |         ^^^ expected identifier, found keyword
    |
help: you can escape reserved keywords to use them as identifiers
    |
581 |     pub r#dyn: *mut ::std::os::raw::c_void,
    |         ^^^^^

error: unions cannot have zero fields
   --> src/ffi/pfvar.rs:580:1
    |
580 | / pub union pf_addr_wrap__bindgen_ty_2 {
581 | |     pub dyn: *mut ::std::os::raw::c_void,
582 | |     pub tbl: *mut ::std::os::raw::c_void,
583 | |     pub dyncnt: ::std::os::raw::c_int,
584 | |     pub tblcnt: ::std::os::raw::c_int,
585 | |     _bindgen_union_align: u64,
586 | | }
    | |_^

and/or

// Insert the (incorrect/buggy) generated bindings here

and/or

Insert compilation errors generated when compiling the bindings with rustc here

Expected Results

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions