Skip to content

Interaction between wrapped statics and redefined function #2420

Open
@Urgau

Description

@Urgau

Input C/C++ Header

static inline int foo(int a, int b) {
    return a + b;
}

#define foo(a) foo(a, a + 5)

Bindgen Invocation

$ bindgen --experimental --wrap-static-fns input.h

Actual Results

extern "C" {
    #[link_name = "\u{1}foo__extern"]
    pub fn foo(a: ::std::os::raw::c_int, b: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
}

and

int foo__extern(int a, int b) asm("foo__extern");
int foo__extern(int a, int b) { return foo(a, b); }

and compiling the C wrapper:

$ cc -include input.h /tmp/bindgen/extern.c
/tmp/bindgen/extern.c: In function 'foo__extern':
/tmp/bindgen/extern.c:2:48: error: macro "foo" passed 2 arguments, but takes just 1
    2 | int foo__extern(int a, int b) { return foo(a, b); }
      |                                                ^
In file included from <command-line>:
./input.h:5: note: macro "foo" defined here
    5 | #define foo(a) foo(a, a + 5)

Expected Results

I don't really know. Is this something that should work? If yes, how ?

cc @pvdrz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions