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

C API: Use opaque structs instead of void #10561

Closed
roberth opened this issue Apr 19, 2024 · 0 comments · Fixed by #10907
Closed

C API: Use opaque structs instead of void #10561

roberth opened this issue Apr 19, 2024 · 0 comments · Fixed by #10907
Labels
c api Nix as a C library with a stable interface feature Feature request or proposal
Milestone

Comments

@roberth
Copy link
Member

roberth commented Apr 19, 2024

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.

@roberth roberth added feature Feature request or proposal c api Nix as a C library with a stable interface labels Apr 19, 2024
@roberth roberth added this to the Stable C API milestone Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c api Nix as a C library with a stable interface feature Feature request or proposal
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant