Skip to content

When not using --enable-cxx-namespaces, structs with same name in different namespaces end up as conflicting definitions #267

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

Closed
fitzgen opened this issue Nov 15, 2016 · 2 comments

Comments

@fitzgen
Copy link
Member

fitzgen commented Nov 15, 2016

Input:

namespace JS {

    struct Zone;

    namespace shadow {

        struct Zone {
            int x;
            int y;
        };
    }
}

Output:

/* automatically generated by rust-bindgen */

#[repr(C)]
#[derive(Debug, Copy)]
pub struct Zone {
    pub _address: u8,
}
impl Clone for Zone {
    fn clone(&self) -> Self { *self }
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Zone {
    pub x: ::std::os::raw::c_int,
    pub y: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_Zone() {
    assert_eq!(::std::mem::size_of::<Zone>() , 8usize);
    assert_eq!(::std::mem::align_of::<Zone>() , 4usize);
}
impl Clone for Zone {
    fn clone(&self) -> Self { *self }
}
@fitzgen
Copy link
Member Author

fitzgen commented Nov 15, 2016

I'll reuse the infrastructure we have for overloaded functions, I guess.

@emilio
Copy link
Contributor

emilio commented Nov 15, 2016

Hmm I'd expect namespace names to influence that...

bors-servo pushed a commit that referenced this issue Nov 18, 2016
Include namespaces in mangled symbols

When we aren't using `--enable-cxx-namespaces`, we can end up with
conflicting struct symbol names that we need to disambiguate. The
solution is to mangle the namespaced C++ symbol "foo::bar::Baz" into the
Rust "foo_bar_Baz" symbol.

This did change the way anonymous types and modules get named a little,
but I think our approach is much more sane now than it was before.

Fixes #267.

r? @emilio
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

2 participants