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

typedef on Templates causes weird issues on overloaded functions #1382

Open
uttarayan21 opened this issue Jul 18, 2024 · 2 comments
Open

typedef on Templates causes weird issues on overloaded functions #1382

uttarayan21 opened this issue Jul 18, 2024 · 2 comments

Comments

@uttarayan21
Copy link
Contributor

uttarayan21 commented Jul 18, 2024

Describe the bug.
I'm trying to link to an existing c++ library
but If typedef is used on overloaded function arguments. it makes the system not be able to compile

To Reproduce
Please see the repo here

use autocxx::prelude::*;
include_cpp! {
    #include "demo.hpp"
    safety!(unsafe_ffi)
    generate!("DEMO::Demo")
}
#pragma once
#include <functional>
#include <map>
#include <memory>
#include <string>
namespace DEMO {
class FooBar;
typedef std::pair<std::map<int, std::shared_ptr<FooBar>>,
                  std::shared_ptr<FooBar>>
    Baz;
// typedef std::pair<int, FooBar> Baz;
struct Bar;
class Foo;
class Demo {
public:
  Foo *createFoo(const Bar &bar);
  // This works
  // Foo *createFoo(const Bar &bar,
  //                const std::pair<std::map<int, std::shared_ptr<FooBar>>,
  //                                std::shared_ptr<FooBar>> &baz);
  // This doesn't
  Foo *createFoo(const Bar &bar, Baz &baz);
};
} // namespace DEMO

Expected behavior
Should compile fine with the typedef.

Additional context
Removing the typedef and replacing with the actual types works fine.

Also I'm quite new to c++ so I'm not sure If I'm doing something wrong.

@adetaylor
Copy link
Collaborator

Please see the docs for how to raise a test case PR if you'd like me to look at this.

@adetaylor
Copy link
Collaborator

Thanks for the report, and especially, for raising the PR with the test case.

Unfortunately, the problem here lies within bindgen. It's telling us:

pub type Arg = u8;

which isn't true. You could consider raising an upstream bindgen bug. Then again, bindgen continuously improves in its handling of cases like this, so it might be fixed soon or perhaps already. I'm in the process of doing a bindgen roll so that's the first thing to try.

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