Re: using Unsized Arrays in Structures from d?

2018-05-04 Thread NewUser via Digitalmars-d-learn
On Friday, 4 May 2018 at 15:37:28 UTC, ag0aep6g wrote: On Friday, 4 May 2018 at 13:02:08 UTC, NewUser wrote: How can I use the following c structure from d. struct Item { int id; }; struct Group { int i; int item_count; struct Item items[]; }; tried defining items[] as both "Item[]

Re: using Unsized Arrays in Structures from d?

2018-05-04 Thread ag0aep6g via Digitalmars-d-learn
On Friday, 4 May 2018 at 13:02:08 UTC, NewUser wrote: How can I use the following c structure from d. struct Item { int id; }; struct Group { int i; int item_count; struct Item items[]; }; tried defining items[] as both "Item[] items" and "Item* items" in d, it compiles okay but

Re: using Unsized Arrays in Structures from d?

2018-05-04 Thread NewUser via Digitalmars-d-learn
On Friday, 4 May 2018 at 14:55:18 UTC, Timoses wrote: On Friday, 4 May 2018 at 13:27:03 UTC, NewUser wrote: Hi Timoses, The structure is being returned from c and I'd like use it from d. What you have work perfectly when assigning from d. Regards, NewUser Then you probably need some

Re: using Unsized Arrays in Structures from d?

2018-05-04 Thread Timoses via Digitalmars-d-learn
On Friday, 4 May 2018 at 13:27:03 UTC, NewUser wrote: Hi Timoses, The structure is being returned from c and I'd like use it from d. What you have work perfectly when assigning from d. Regards, NewUser Then you probably need some `extern(C)` statement introducing the C function and the

Re: using Unsized Arrays in Structures from d?

2018-05-04 Thread NewUser via Digitalmars-d-learn
On Friday, 4 May 2018 at 13:21:53 UTC, Timoses wrote: On Friday, 4 May 2018 at 13:02:08 UTC, NewUser wrote: tried defining items[] as both "Item[] items" and "Item* items" in d, it compiles okay but gives an error when trying to access it. You were on the right track. D array notation is:

Re: using Unsized Arrays in Structures from d?

2018-05-04 Thread Timoses via Digitalmars-d-learn
On Friday, 4 May 2018 at 13:02:08 UTC, NewUser wrote: tried defining items[] as both "Item[] items" and "Item* items" in d, it compiles okay but gives an error when trying to access it. You were on the right track. D array notation is: [] ; For me this works: ``` struct Item { int id; };

Re: using Unsized Arrays in Structures from d?

2018-05-04 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 4 May 2018 at 13:02:08 UTC, NewUser wrote: How can I use the following c structure from d. struct Item { int id; }; struct Group { int i; int item_count; struct Item items[]; }; tried defining items[] as both "Item[] items" and "Item* items" in d, it compiles okay but

using Unsized Arrays in Structures from d?

2018-05-04 Thread NewUser via Digitalmars-d-learn
Hi, How can I use the following c structure from d. struct Item { int id; }; struct Group { int i; int item_count; struct Item items[]; }; tried defining items[] as both "Item[] items" and "Item* items" in d, it compiles okay but gives an error when trying to access it. Here is