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

Config feature and Export macros don't get along #2122

Open
pacu opened this issue May 21, 2024 · 1 comment
Open

Config feature and Export macros don't get along #2122

pacu opened this issue May 21, 2024 · 1 comment

Comments

@pacu
Copy link

pacu commented May 21, 2024

uniffi = "0.27.0"

Problem: cfg(feature = ) and uniffi::export macros don't get along

context:

I'm working on this FROST signatures wrapper with uniffi.
https://github.com/pacu/frost-mobile-sdk

I can build the FROST dependency with or without the redpallas feature flag. That would change some arguments on the FFI exposed to the client.

#[uniffi::export]
pub fn aggregate(
    signing_package: FrostSigningPackage, 
    signature_shares: Vec<FrostSignatureShare>,
    pubkey_package: FrostPublicKeyPackage,
    #[cfg(feature = "redpallas")]
    randomizer: FrostRandomizer,
) -> Result<FrostSignature, CoordinationError> 

This works fine if I build the project with the redpallas feature enabled. But it fails when I don't enable it.

error[E0061]: this function takes 3 arguments but 4 arguments were supplied
   --> frost-mobile-sdk/src/coordinator.rs:106:8
    |
105 | #[uniffi::export]
    | ----------------- unexpected argument
106 | pub fn aggregate(
    |        ^^^^^^^^^

Is this expected as a limitation of uniffi? or is it real problem?

possibly related:

#2000

@rafaelbeckel
Copy link
Contributor

It's not exactly related to the other issue. In my understanding, you are changing the function signature when you do not enable the feature (you remove the 4th parameter), so you have to add the same #[cfg()] annotation in the caller's 4th argument to remove it too.

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