Skip to content

Bug in cxxbridge-cmd? Generated incorrect namespace #441

@XiangpengHao

Description

@XiangpengHao

Hi, I encountered this after upgrading the cxxbridge-cmd to 0.5.6:

// lib.rs
#[cxx::bridge(namespace = rust_part)]
mod ffi {
    extern "C++" {
        type Person;
        fn get_name(person: &Person) -> &CxxString;
    }
}

Run cxxbridge:

cxxbridge lib.rs --header
cxxbridge lib.rs

And get the header:

#pragma once
#include <string>

namespace rust_part {
  using Person = ::rust_part::Person;
}

and source:

#include <string>

namespace rust_part {
  using Person = ::rust_part::Person;
}

namespace rust_part {
extern "C" {
const ::std::string *rust_part$cxxbridge05$get_name(const ::rust_part::Person &person) noexcept {
  const ::std::string &(*get_name$)(const ::rust_part::Person &) = ::rust_part::get_name;
  return &get_name$(person);
}
} // extern "C"
} // namespace rust_part

I suppose the Person should not be in rust_part namespace, in fact (at least) in 0.5.2 it yields the following code and compiles for me.

#pragma once
#include <string>

namespace rust_part {

using Person = Person;

} // namespace rust_part

Am I missing something? This also relates to the problem discussed #434

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions