Skip to content

allow implicit cast from *T to ?*c_void #433

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

Closed
andrewrk opened this issue Aug 27, 2017 · 5 comments
Closed

allow implicit cast from *T to ?*c_void #433

andrewrk opened this issue Aug 27, 2017 · 5 comments
Labels
accepted This proposal is planned. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented Aug 27, 2017

Should we allow implicitly casting pointers to ?*c_void?

@andrewrk andrewrk added the enhancement Solving this issue will likely involve adding new logic or components to the codebase. label Aug 27, 2017
@andrewrk andrewrk added this to the 0.2.0 milestone Aug 27, 2017
@raulgrell
Copy link
Contributor

This looks both convenient for reducing clutter in code, and should be perfectly safe, but seeing the cast to ?&c_void is a nice reminder that you are interfacing with unsafe/c code.

@andrewrk andrewrk modified the milestones: 0.2.0, 0.3.0 Nov 14, 2017
@andrewrk andrewrk modified the milestones: 0.3.0, 0.4.0 Feb 28, 2018
@raulgrell
Copy link
Contributor

I've been interfacing with more and more C code and especially with the new developments around casting I think this feature would be pretty welcome.

@andrewrk
Copy link
Member Author

I appreciate that feedback. What do you think about the proposal to add another pointer type specifically for C interop? #1059

@andrewrk andrewrk added proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. and removed enhancement Solving this issue will likely involve adding new logic or components to the codebase. labels Aug 25, 2018
@raulgrell
Copy link
Contributor

Yet another pointer type sounds awful, but the convenience of not having to manually correct your imports is really tempting... I think Zig has to do everything it can to make C interop completely seamless. I'll comment more on that issue's thread.

Since any 'real' binding to a C library need work beyond what translate-c can do, any problems inherent to this kind of pointer won't be an issue for 'real code'. I say go for it.

@andrewrk andrewrk changed the title allow implicit cast from &T to ?&c_void allow implicit cast from &T to ?*c_void Aug 25, 2018
@andrewrk andrewrk changed the title allow implicit cast from &T to ?*c_void allow implicit cast from *T to ?*c_void Aug 25, 2018
@andrewrk andrewrk added the accepted This proposal is planned. label Aug 25, 2018
@andrewrk
Copy link
Member Author

implemented in e2a9f2e by @raulgrell

@andrewrk andrewrk modified the milestones: 0.4.0, 0.3.0 Aug 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted This proposal is planned. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Projects
None yet
Development

No branches or pull requests

2 participants