Giter Site home page Giter Site logo

Comments (6)

Sean1708 avatar Sean1708 commented on July 17, 2024

See here for info on representation.

from rusty-cheddar.

Sean1708 avatar Sean1708 commented on July 17, 2024

The docs suggest using an empty enum for opaque structs, but these can't be #[repr(C)].

What about unit structs?

from rusty-cheddar.

Sean1708 avatar Sean1708 commented on July 17, 2024

Even the enum would be easy enough to support, just check the variants are empty before checking for #[repr(C)] and special case that.

from rusty-cheddar.

Sean1708 avatar Sean1708 commented on July 17, 2024

Thinking about it, you can't use empty enums for opaque structs because they need to be not opaque on the Rust side.

Instead I think private #[repr(C)] structs should be opaque structs.

from rusty-cheddar.

Sean1708 avatar Sean1708 commented on July 17, 2024

The two current thoughts for opaque structs are

struct NonOpaque {
    b: f64,
}

// typedef struct Opaque Opaque;
#[repr(C)]
pub struct Opaque(NonOpaque);

À la this playground. So any public #[repr(C)] newtype would be an opaque struct that would have to be handled via pointers in C.

Alternatively have any public #[repr(C)] struct with only private members be an opaque struct, this feels too magic to me though.

from rusty-cheddar.

Sean1708 avatar Sean1708 commented on July 17, 2024

Closed by b6a7cc1

from rusty-cheddar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.