-
Notifications
You must be signed in to change notification settings - Fork 162
Open
Description
Describe the bug
When my C++ header contains nested typedef, like so (header.hpp):
#pragma once
#include <functional>
class Foo {
public:
typedef std::function<void(int)> CallbackType; // <-- this is the problem
explicit Foo(const CallbackType &cb) {}
};Any my bindings use it (main.rs):
use autocxx::prelude::*;
include_cpp!(
#include "header.hpp"
safety!(unsafe_ffi)
generate!("Foo")
);Then cargo build fails, because it places CallbackType inside a namespace Foo like so:
namespace Foo {
using CallbackType = ::Foo::CallbackType;
}And then C++ compilation fails with:
target\debug\build\rust-autocxx-b49661854cba97fb\out\autocxx-build-dir\cxx\gen0.cxx(147): error C2757: 'Foo': a symbol with this name already exists and therefore this name cannot be used as a namespace name
To Reproduce
Use src/header.hpp, src/main.rs and build.rs:
fn main() {
autocxx_build::Builder::new(&"src/main.rs", &[&"src"])
.build()
.expect("Unable to build C++ bindings")
.compile("autocxx-demo");
println!("cargo:rerun-if-changed={}", "src/main.rs");
}Expected behavior
Rust binding correctly generated, no C++ compilation error
Additional context
None
Metadata
Metadata
Assignees
Labels
No labels