Thread overview | |||||
---|---|---|---|---|---|
|
February 10, 2019 New Blog Post: Writing a D Wrapper for a C Library | ||||
---|---|---|---|---|
| ||||
Victor Porton decided to port an app he developed for a research project from Ada to D. In the process, he created a bindings and a wrapper for a C library, librdf. In this post, he shares the approach he took to translating the C API into the D wrapper. The blog: https://dlang.org/blog/2019/02/10/writing-a-d-wrapper-for-a-c-library/ Reddit: https://www.reddit.com/r/programming/comments/ap47uf/writing_a_d_wrapper_for_a_c_library/ |
February 10, 2019 Re: New Blog Post: Writing a D Wrapper for a C Library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On 10.02.19 15:19, Mike Parker wrote:
> https://dlang.org/blog/2019/02/10/writing-a-d-wrapper-for-a-c-library/
As far as I see, `context` shouldn't be const.
You cast a const `this` to non-const void* and then "back" to non-const UserIOStream. Then doWriteBytes is called on this seemingly mutable object that's actually const.
If I implement doWriteBytes in a way that mutates the object, I'm violating const.
|
February 10, 2019 Re: New Blog Post: Writing a D Wrapper for a C Library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On 2/10/2019 6:19 AM, Mike Parker wrote: > Victor Porton decided to port an app he developed for a research project from Ada to D. In the process, he created a bindings and a wrapper for a C library, librdf. In this post, he shares the approach he took to translating the C API into the D wrapper. > > The blog: > https://dlang.org/blog/2019/02/10/writing-a-d-wrapper-for-a-c-library/ > > > Reddit: > https://www.reddit.com/r/programming/comments/ap47uf/writing_a_d_wrapper_for_a_c_library/ It's on the front page (number 8) of Hacker News. https://news.ycombinator.com/news |
Copyright © 1999-2021 by the D Language Foundation