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

#[cxx::bridge] doesn't apply #[cfg(not(feature))] #1299

Open
hombit opened this issue Jan 3, 2024 · 0 comments
Open

#[cxx::bridge] doesn't apply #[cfg(not(feature))] #1299

hombit opened this issue Jan 3, 2024 · 0 comments

Comments

@hombit
Copy link

hombit commented Jan 3, 2024

It looks like #[cfg(not(feature))] is ignored by #[cxx::bridge], so the marked field would always exist:

mod ffi {
    #[repr(u32)]
    enum Variant {
        #[cfg(not(feature = "v2"))]
        A,
        B,
    }
}

See this demo repo for a reproducible example.

#[cfg(not(feature))] is useful when a newer version of a C++ library dropped something, while we would like to support both new and old versions with Cargo feature flags.

@hombit hombit changed the title #[cfg(not(feature))] inside #[cxx::bridge] #[cxx::bridge] doesn't apply #[cfg(not(feature))] Jan 3, 2024
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

1 participant