Skip to content

C API: Use opaque structs instead of void #10561

@roberth

Description

@roberth

Is your feature request related to a problem? Please describe.

  • Currently the C compiler will not catch certain errors such as switched arguments, because all void * typedefs are assumed interchangeable.
  • Similarly, generated bindings forward the problem.

Describe the solution you'd like

Use forward declarations.

struct nix_foo;
typedef struct nix_foo nix_foo;

Describe alternatives you've considered

Maybe some bindings generator had an annoying behavior, compared to void pointers? I find this unlikely.

Additional context

Priorities

Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c apiNix as a C library with a stable interfacefeatureFeature request or proposal

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions