digitalmars.D.learn - Pointer to private structure
- Nikhil Jacob (8/8) Dec 18 2016 In C, we can define a struct without body in an include file and
- Nicholas Wilson (2/10) Dec 18 2016 Yes.
- ketmar (2/2) Dec 18 2016 i bet that just trying this with D compiler will take less time
- Nikhil Jacob (3/5) Dec 18 2016 I did try but it seems to give compilation failure... Let me try
- Ali (13/18) Dec 19 2016 What're you trying to do here?
- Nikhil Jacob (4/19) Dec 19 2016 I was trying to do something similar to pimlp idiom.
In C, we can define a struct without body in an include file and use pointer to that structure For examples in public header file. struct data; data* new_data(); We can then define the elements of struct data privately inside the implementation of library. Can we do this in D without using void* ?
Dec 18 2016
On Monday, 19 December 2016 at 05:51:09 UTC, Nikhil Jacob wrote:In C, we can define a struct without body in an include file and use pointer to that structure For examples in public header file. struct data; data* new_data(); We can then define the elements of struct data privately inside the implementation of library. Can we do this in D without using void* ?Yes.
Dec 18 2016
i bet that just trying this with D compiler will take less time than writing forum post.
Dec 18 2016
On Monday, 19 December 2016 at 06:21:10 UTC, ketmar wrote:i bet that just trying this with D compiler will take less time than writing forum post.I did try but it seems to give compilation failure... Let me try once more and I will get back with more details.
Dec 18 2016
On Monday, 19 December 2016 at 06:42:27 UTC, Nikhil Jacob wrote:On Monday, 19 December 2016 at 06:21:10 UTC, ketmar wrote:What're you trying to do here? Forward declarations in C++ are used to solve a few different things: 1. Reduce build times (unneeded in D AFAIK) 2. Break cyclic references (unneeded in D again?) 3. Give APIs visibility (D's modules and Access layers solve this) 4. Maintain binary compatibility while allowing internal data changes (aka pimlp idiom) <-- This I believe you cannot do in D - https://wiki.dlang.org/Access_specifiers_and_visibility (someone correct me if I'm wrong) I've seen something about .di files in D. But they seem flakey a bit.i bet that just trying this with D compiler will take less time than writing forum post.I did try but it seems to give compilation failure... Let me try once more and I will get back with more details.
Dec 19 2016
On Monday, 19 December 2016 at 10:14:49 UTC, Ali wrote:On Monday, 19 December 2016 at 06:42:27 UTC, Nikhil Jacob wrote:I was trying to do something similar to pimlp idiom. But after thinking over it, I found a better way in D. Thanks for pointing to the wiki[...]What're you trying to do here? Forward declarations in C++ are used to solve a few different things: 1. Reduce build times (unneeded in D AFAIK) 2. Break cyclic references (unneeded in D again?) 3. Give APIs visibility (D's modules and Access layers solve this) 4. Maintain binary compatibility while allowing internal data changes (aka pimlp idiom) <-- This I believe you cannot do in D - https://wiki.dlang.org/Access_specifiers_and_visibility (someone correct me if I'm wrong) I've seen something about .di files in D. But they seem flakey a bit.
Dec 19 2016