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

[Feature request] Allow macro inside cxx::bridge #807

Closed
mikhailzagurskiy opened this issue Apr 2, 2021 · 2 comments
Closed

[Feature request] Allow macro inside cxx::bridge #807

mikhailzagurskiy opened this issue Apr 2, 2021 · 2 comments

Comments

@mikhailzagurskiy
Copy link

When we write a lot of similar wrappers, it would be great to use macro to simplify their declaration:

macro_rules! impl_interface {
  ($ty:ty) => {
    paste::item! {
       fn [<_I $ty _method1>](&self) -> u64 ;
    }
  }
}

#[cxx::bridge]
mod ffi {
  unsafe extern "C++" {
    impl_interface!(Class1);
    impl_interface!(Class2);
    impl_interface!(Class3);
    impl_interface!(Class4);
  }
}

I can do it in implementation, but can't in declaration

@andfoy
Copy link

andfoy commented Apr 6, 2021

I think this is a duplicate of #274

@mikhailzagurskiy
Copy link
Author

Yes, thank you. It's a duplicate. Will close this.

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