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

wrap_static_fns not generating extern.c when -x c++ #3157

Open
sehnryr opened this issue Feb 25, 2025 · 0 comments · May be fixed by #3165
Open

wrap_static_fns not generating extern.c when -x c++ #3157

sehnryr opened this issue Feb 25, 2025 · 0 comments · May be fixed by #3165

Comments

@sehnryr
Copy link

sehnryr commented Feb 25, 2025

Calling option wrap-static-fns with -x c++ to force C++ mode (this also happens when simply calling bindgen on a .hpp file) (https://rust-lang.github.io/rust-bindgen/cpp.html) fails to create extern.cpp.

Considering this simple test.h file:

static void testing();

Calling bindgen with -x c++ to force C++ mode:

❯ bindgen test.h --wrap-static-fns -- -x c++
/* automatically generated by rust-bindgen 0.71.1 */

unsafe extern "C" {
    #[link_name = "\u{1}_ZL7testingv"]
    pub fn testing();
}

Doesn't generate extern.c at the default path (/tmp/bindgen on unix systems):

❯ cat /tmp/bindgen/extern.cpp 
cat: /tmp/bindgen/extern.cpp: No such file or directory

Here's the default behavior without C++ mode (or .hpp):

❯ bindgen test.h --wrap-static-fns
/* automatically generated by rust-bindgen 0.71.1 */

unsafe extern "C" {
    #[link_name = "testing__extern"]
    pub fn testing();
}

Which does generate the static wrapper:

❯ cat /tmp/bindgen/extern.c
#include "test.h"

// Static wrappers

void testing__extern(void) { testing(); }
@sehnryr sehnryr linked a pull request Feb 26, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant