Re: static init c struct with array filed

2022-03-16 Thread Adam Ruppe via Digitalmars-d-learn
On Thursday, 17 March 2022 at 00:16:39 UTC, Mike Parker wrote: On Wednesday, 16 March 2022 at 07:27:06 UTC, test wrote: ```c struct Test { int32_t a; } struct Test2 { int32_t a; Test arr[]; } ``` I need static const init Test2, then pass it to c library late(third library, can not

Re: static init c struct with array filed

2022-03-16 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 16 March 2022 at 07:27:06 UTC, test wrote: ```c struct Test { int32_t a; } struct Test2 { int32_t a; Test arr[]; } ``` I need static const init Test2, then pass it to c library late(third library, can not change the type def). Any time you see a '[]' in C, the equi

Re: static init c struct with array filed

2022-03-16 Thread Ali Çehreli via Digitalmars-d-learn
On 3/16/22 10:03, user1234 wrote: > On Wednesday, 16 March 2022 at 14:42:02 UTC, Era Scarecrow wrote: >> On Wednesday, 16 March 2022 at 11:27:20 UTC, user1234 wrote: >>> assuming the c library takes by reference >> >> My experience all arrays are effectively just pointers > > I meant the function

Re: static init c struct with array filed

2022-03-16 Thread user1234 via Digitalmars-d-learn
On Wednesday, 16 March 2022 at 14:42:02 UTC, Era Scarecrow wrote: On Wednesday, 16 March 2022 at 11:27:20 UTC, user1234 wrote: assuming the c library takes by reference My experience all arrays are effectively just pointers I meant the function that takes the Test2 as parameter, but to be

Re: static init c struct with array filed

2022-03-16 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 16 March 2022 at 11:27:20 UTC, user1234 wrote: assuming the c library takes by reference My experience all arrays are effectively just pointers, and the brackets/length is only really applicable to stack allocated fixed length allocations. In my own C projects i always used po

Re: static init c struct with array filed

2022-03-16 Thread user1234 via Digitalmars-d-learn
On Wednesday, 16 March 2022 at 07:27:06 UTC, test wrote: ```c struct Test { int32_t a; } struct Test2 { int32_t a; Test arr[]; } ``` I need static const init Test2, then pass it to c library late(third library, can not change the type def). I am not sure how to do it in D. ```d

static init c struct with array filed

2022-03-16 Thread test via Digitalmars-d-learn
```c struct Test { int32_t a; } struct Test2 { int32_t a; Test arr[]; } ``` I need static const init Test2, then pass it to c library late(third library, can not change the type def). I am not sure how to do it in D.