static init c struct with array filed

Adam Ruppe destructionator at gmail.com
Thu Mar 17 00:48:56 UTC 2022


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 change the type def).
>>
>
> Any time you see a '[]' in C, the equivalent declaration in D 
> has to be a pointer.

Not always with structs....... if it has a fixed size or an 
initializer in C, then you need to match the size in D.

Otherwise yeah use the pointer.



More information about the Digitalmars-d-learn mailing list